diff --git a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java index f315816f4..0e006fcce 100644 --- a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java +++ b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.content.Context; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.text.TextUtils; import android.widget.ImageView; import androidx.annotation.NonNull; @@ -12,7 +13,6 @@ import androidx.annotation.Nullable; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.CustomTarget; -import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.transition.Transition; import com.yunbao.common.R; @@ -127,23 +127,32 @@ public class ImgLoader { public static void displayDrawable(Context context, String url, final DrawableCallback callback) { if (!contextIsExist(context)) { + return; } - Glide.with(context).asDrawable().load(url).skipMemoryCache(SKIP_MEMORY_CACHE).into(new CustomTarget() { + if (TextUtils.isEmpty(url)) { + if (callback != null) + callback.onLoadFailed(); + } else { + Glide.with(context).asDrawable().load(url).skipMemoryCache(SKIP_MEMORY_CACHE).into(new CustomTarget() { - @Override - public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) { - if (callback != null) { - callback.onLoadSuccess(resource); + @Override + public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) { + if (callback != null) { + callback.onLoadSuccess(resource); + } } - } - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } + }); + } + - } - }); } + public static void displayFileDrawable(Context context, File file, final DrawableCallback callback) { if (!contextIsExist(context)) { return;