many improvement

androidx
Zhanty 5 years ago
parent a9c0fe36b5
commit a5d4fa1a51
  1. 1
      config/repository.gradle
  2. 26
      lib_base/src/main/java/com/android/base/app/aac/SingleLiveData.java
  3. 20
      lib_base/src/main/java/com/android/base/kotlin/ViewEx.kt
  4. 1
      lib_base/src/main/res/values-en/base_strings.xml
  5. 7
      lib_media_selector/README.md
  6. 15
      lib_media_selector/build.gradle
  7. 24
      lib_social/src/main/java/com/android/sdk/social/wechat/SingleLiveData.java

@ -258,6 +258,7 @@ static Repository innerNewRepository() {
/*image view about*/ /*image view about*/
//https://github.com/chrisbanes/PhotoView //https://github.com/chrisbanes/PhotoView
photoView : 'com.github.chrisbanes:PhotoView:2.1.3', photoView : 'com.github.chrisbanes:PhotoView:2.1.3',
rotatePhotoView :'com.chensl.rotatephotoview:rotatephotoview:1.0.5',
//https://github.com/davemorrissey/subsampling-scale-image-view //https://github.com/davemorrissey/subsampling-scale-image-view
subsamplingScaleImageView: 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0', subsamplingScaleImageView: 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0',
//https://github.com/hdodenhof/CircleImageView //https://github.com/hdodenhof/CircleImageView

@ -19,7 +19,6 @@ public class SingleLiveData<T> extends MediatorLiveData<T> {
private final List<WeakReference<ObserverWrapper<T>>> mWrapperObserverList = new ArrayList<>(); private final List<WeakReference<ObserverWrapper<T>>> mWrapperObserverList = new ArrayList<>();
@Override @Override
public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<T> observer) { public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<T> observer) {
super.observe(owner, getOrNewObserver(observer, mVersion)); super.observe(owner, getOrNewObserver(observer, mVersion));
@ -38,10 +37,27 @@ public class SingleLiveData<T> extends MediatorLiveData<T> {
@Override @Override
public void removeObserver(@NonNull Observer<T> observer) { public void removeObserver(@NonNull Observer<T> observer) {
Observer<T> wrapper = findWrapper(observer); if (observer instanceof ObserverWrapper) {
Timber.d("removeObserver() called with: observer = [" + observer + "], wrapper = [" + wrapper + "]"); super.removeObserver(observer);
if (wrapper != null) { removeWrapper((ObserverWrapper) observer);
Timber.d("removeObserver() called with: observer = wrapper = [" + observer + "]");
} else {
ObserverWrapper<T> wrapper = findWrapper(observer);
Timber.d("removeObserver() called with: observer = [" + observer + "], wrapper = [" + wrapper + "]");
super.removeObserver(wrapper); super.removeObserver(wrapper);
removeWrapper(wrapper);
}
}
private void removeWrapper(ObserverWrapper observer) {
ListIterator<WeakReference<ObserverWrapper<T>>> iterator = mWrapperObserverList.listIterator();
while (iterator.hasNext()) {
WeakReference<ObserverWrapper<T>> next = iterator.next();
ObserverWrapper<T> item = next.get();
if (item == observer) {
iterator.remove();
break;
}
} }
} }
@ -56,7 +72,7 @@ public class SingleLiveData<T> extends MediatorLiveData<T> {
if (item == null) { if (item == null) {
iterator.remove(); iterator.remove();
} else if (item.mOrigin == observer) { } else if (item.mOrigin == observer) {
target = item; target = item;
} }
} }

@ -5,9 +5,13 @@ import android.support.annotation.ColorRes
import android.support.annotation.DrawableRes import android.support.annotation.DrawableRes
import android.support.v4.content.ContextCompat import android.support.v4.content.ContextCompat
import android.support.v4.view.ViewCompat import android.support.v4.view.ViewCompat
import android.support.v4.widget.NestedScrollView
import android.view.View import android.view.View
import android.view.View.FOCUS_DOWN
import android.view.View.FOCUS_UP
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewTreeObserver import android.view.ViewTreeObserver
import android.widget.ScrollView
import com.android.base.rx.subscribeIgnoreError import com.android.base.rx.subscribeIgnoreError
import com.android.base.utils.android.ViewUtils import com.android.base.utils.android.ViewUtils
import com.android.base.utils.android.compat.AndroidVersion.atLeast import com.android.base.utils.android.compat.AndroidVersion.atLeast
@ -150,3 +154,19 @@ fun View.onClickObservable(milliseconds: Long): Observable<Any> {
} }
inline val ViewGroup.views get() = (0 until childCount).map { getChildAt(it) } inline val ViewGroup.views get() = (0 until childCount).map { getChildAt(it) }
fun ScrollView.scrollToBottom() {
fullScroll(FOCUS_DOWN)
}
fun ScrollView.scrollToTop() {
fullScroll(FOCUS_UP)
}
fun NestedScrollView.scrollToBottom() {
fullScroll(FOCUS_DOWN)
}
fun NestedScrollView.scrollToTop() {
fullScroll(FOCUS_UP)
}

@ -3,7 +3,6 @@
<string name="Base_Confirm">Confirm</string> <string name="Base_Confirm">Confirm</string>
<string name="Base_Cancel">Cancel</string> <string name="Base_Cancel">Cancel</string>
<!-- ================== error layout ================== --> <!-- ================== error layout ================== -->
<string name="base_error_load_fail_tips">Failed to load/(ㄒoㄒ)/~~ </string> <string name="base_error_load_fail_tips">Failed to load/(ㄒoㄒ)/~~ </string>
<string name="base_error_retry_action_tips">Click me to retry</string> <string name="base_error_retry_action_tips">Click me to retry</string>

@ -23,5 +23,10 @@
## 3 其他备选参考 ## 3 其他备选参考
-  [boxing](https://github.com/Bilibili/boxing) -  [boxing](https://github.com/Bilibili/boxing)
-  [uCrop](https://github.com/Yalantis/uCrop) -  [Matisse](https://github.com/zhihu/Matisse)
-  [ImagePicker](https://github.com/jeasonlzy/ImagePicker) -  [ImagePicker](https://github.com/jeasonlzy/ImagePicker)
-  [PictureSelector](https://github.com/LuckSiege/PictureSelector)
-  [Album](https://github.com/yanzhenjie/Album)
-  [uCrop](https://github.com/Yalantis/uCrop)
-  [smartCropper](https://github.com/pqpo/SmartCropper)
-  [simpleCropper](https:github.com/igreenwood/SimpleCropView)

@ -32,11 +32,6 @@ dependencies {
/*imageLoader*/ /*imageLoader*/
compileOnly thirdLibraries.glide compileOnly thirdLibraries.glide
//other optional
// Matissehttps://github.com/zhihu/Matisse
//PictureSelector https://github.com/LuckSiege/PictureSelector
//Albumhttps://github.com/yanzhenjie/Album
implementation('com.bilibili:boxing:1.0.4') { implementation('com.bilibili:boxing:1.0.4') {
exclude group: 'com.android.support' exclude group: 'com.android.support'
} }
@ -45,10 +40,12 @@ dependencies {
exclude group: 'com.android.support' exclude group: 'com.android.support'
} }
//other optional implementation('com.chensl.rotatephotoview:rotatephotoview:1.0.5') {
//cropper about exclude group: 'com.android.support', module: 'appcompat'
// smartCropperhttps://github.com/pqpo/SmartCropper exclude group: 'com.android.support', module: 'support-v4'
// simpleCropperhttps:github.com/igreenwood/SimpleCropView exclude module: 'recyclerview-v7'
}
implementation('com.yalantis:ucrop:2.2.0') { implementation('com.yalantis:ucrop:2.2.0') {
exclude group: 'com.android.support' exclude group: 'com.android.support'
exclude group: 'com.squareup.okio' exclude group: 'com.squareup.okio'

@ -19,7 +19,6 @@ public class SingleLiveData<T> extends MediatorLiveData<T> {
private final List<WeakReference<ObserverWrapper<T>>> mWrapperObserverList = new ArrayList<>(); private final List<WeakReference<ObserverWrapper<T>>> mWrapperObserverList = new ArrayList<>();
@Override @Override
public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<T> observer) { public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<T> observer) {
super.observe(owner, getOrNewObserver(observer, mVersion)); super.observe(owner, getOrNewObserver(observer, mVersion));
@ -38,10 +37,27 @@ public class SingleLiveData<T> extends MediatorLiveData<T> {
@Override @Override
public void removeObserver(@NonNull Observer<T> observer) { public void removeObserver(@NonNull Observer<T> observer) {
Observer<T> wrapper = findWrapper(observer); if (observer instanceof ObserverWrapper) {
Timber.d("removeObserver() called with: observer = [" + observer + "], wrapper = [" + wrapper + "]"); super.removeObserver(observer);
if (wrapper != null) { removeWrapper((ObserverWrapper) observer);
Timber.d("removeObserver() called with: observer = wrapper = [" + observer + "]");
} else {
ObserverWrapper<T> wrapper = findWrapper(observer);
Timber.d("removeObserver() called with: observer = [" + observer + "], wrapper = [" + wrapper + "]");
super.removeObserver(wrapper); super.removeObserver(wrapper);
removeWrapper(wrapper);
}
}
private void removeWrapper(ObserverWrapper observer) {
ListIterator<WeakReference<ObserverWrapper<T>>> iterator = mWrapperObserverList.listIterator();
while (iterator.hasNext()) {
WeakReference<ObserverWrapper<T>> next = iterator.next();
ObserverWrapper<T> item = next.get();
if (item == observer) {
iterator.remove();
break;
}
} }
} }

Loading…
Cancel
Save