update ImageLoader/AutoDispose

androidx
Ztiany 5 years ago
parent e09842a9c9
commit 32008435cb
  1. 12
      lib_base/src/main/java/com/android/base/imageloader/GlideImageLoader.java
  2. 7
      lib_base/src/main/java/com/android/base/imageloader/Source.java
  3. 8
      lib_base/src/main/java/com/android/base/rx/AutoDispose.kt

@ -16,6 +16,8 @@ import com.bumptech.glide.request.target.ImageViewTarget;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.ExecutionException;
import androidx.annotation.NonNull;
@ -94,7 +96,7 @@ class GlideImageLoader implements ImageLoader {
}
@Override
public void onResourceReady(Drawable resource, @Nullable Transition<? super Drawable> transition) {
public void onResourceReady(@NotNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
super.onResourceReady(resource, transition);
mLoadListener.onLoadSuccess(resource);
}
@ -270,7 +272,7 @@ class GlideImageLoader implements ImageLoader {
requestBuilder = setToRequest(requestBuilder, source);
requestBuilder.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
public void onResourceReady(@NotNull Bitmap resource, Transition<? super Bitmap> transition) {
bitmapLoadListener.onLoadSuccess(resource);
}
@ -368,7 +370,9 @@ class GlideImageLoader implements ImageLoader {
return requestManager.load(source.mResource);
} else if (source.mUri != null) {
return requestManager.load(source.mUri);
} else {
} else if (source.mBytes != null) {
return requestManager.load(source.mBytes);
} else {
throw new IllegalArgumentException("UnSupport source");
}
}
@ -382,6 +386,8 @@ class GlideImageLoader implements ImageLoader {
return requestBuilder.load(source.mResource);
} else if (source.mUri != null) {
return requestBuilder.load(source.mUri);
} else if (source.mBytes != null) {
return requestBuilder.load(source.mBytes);
} else {
throw new IllegalArgumentException("UnSupport source");
}

@ -11,6 +11,7 @@ public class Source {
File mFile;
int mResource;
Uri mUri;
byte[] mBytes;
public static Source create(String url) {
Source source = new Source();
@ -34,6 +35,12 @@ public class Source {
return source;
}
public static Source create(byte[] bytes) {
Source source = new Source();
source.mBytes = bytes;
return source;
}
public static Source create(int resource) {
Source source = new Source();
source.mResource = resource;

@ -2,22 +2,20 @@
package com.android.base.rx
import android.view.View
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import com.uber.autodispose.*
import com.uber.autodispose.AutoDispose.autoDisposable
import com.uber.autodispose.android.ViewScopeProvider
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider
import com.uber.autodispose.lifecycle.LifecycleScopeProvider
import io.reactivex.*
import io.reactivex.disposables.Disposable
import timber.log.Timber
fun View.newScopeProvider() = ViewScopeProvider.from(this)
/**
*@author Ztiany
* Email: ztiany3@gmail.com
* Date : 2019-05-10 14:41
*/
interface AutoDisposeLifecycleScopeProviderEx<T> : LifecycleScopeProvider<T> {
fun <T> Flowable<T>.autoDispose(): FlowableSubscribeProxy<T> {

Loading…
Cancel
Save