From 64d1153e93be679dd4c2f02bab5eef574e5ec2ba Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Tue, 21 Apr 2020 19:24:20 +0800 Subject: [PATCH] android:incase load image url after activity is destroyed --- .../doric/src/main/java/pub/doric/shader/ImageNode.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java b/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java index 89facfc2..decd8adc 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/ImageNode.java @@ -16,6 +16,7 @@ package pub.doric.shader; import android.annotation.SuppressLint; +import android.app.Activity; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Rect; @@ -23,6 +24,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.NinePatchDrawable; +import android.os.Build; import android.text.TextUtils; import android.util.Base64; import android.widget.ImageView; @@ -166,6 +168,11 @@ public class ImageNode extends ViewNode { } private void loadImageUrl(String url) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + if (getContext() instanceof Activity && ((Activity) getContext()).isDestroyed()) { + return; + } + } RequestBuilder requestBuilder = Glide.with(getContext()) .load(url); loadIntoTarget(requestBuilder);