From c95fd2d49c9fd32a7ed187a5d942b8f4f5c0bf1f Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Sat, 17 Sep 2022 14:33:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E9=97=B4=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=B1=95=E7=A4=BA=E4=B8=8D=E5=85=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/glide/ImgLoader.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) 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;