From c8c16c283e43c2247a28b0bfa4bd2b5b1a453794 Mon Sep 17 00:00:00 2001 From: iPel Date: Wed, 31 May 2023 18:22:02 +0800 Subject: [PATCH] fix(android): check imageAdapter result before use --- .../com/tencent/mtt/hippy/views/image/HippyImageView.java | 7 +++++++ .../mtt/supportui/views/asyncimage/AsyncImageView.java | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/android/sdk/src/main/java/com/tencent/mtt/hippy/views/image/HippyImageView.java b/android/sdk/src/main/java/com/tencent/mtt/hippy/views/image/HippyImageView.java index f1670d193bf..60ad4bf46f6 100644 --- a/android/sdk/src/main/java/com/tencent/mtt/hippy/views/image/HippyImageView.java +++ b/android/sdk/src/main/java/com/tencent/mtt/hippy/views/image/HippyImageView.java @@ -456,6 +456,13 @@ protected void handleImageRequest(IDrawableTarget target, int sourceType, Object } } + @Override + protected boolean hasImage(IDrawableTarget resultDrawable) { + return (resultDrawable != null && resultDrawable.getBitmap() != null) + || (resultDrawable != null && resultDrawable.getDrawable() != null) + || (resultDrawable instanceof HippyDrawable && ((HippyDrawable) resultDrawable).getGIF() != null); + } + @Override public void setBorderRadius(float radius, int position) { super.setBorderRadius(radius, position); diff --git a/android/sdk/src/main/java/com/tencent/mtt/supportui/views/asyncimage/AsyncImageView.java b/android/sdk/src/main/java/com/tencent/mtt/supportui/views/asyncimage/AsyncImageView.java index ce29e7f0bcc..fc73ea0e3fd 100644 --- a/android/sdk/src/main/java/com/tencent/mtt/supportui/views/asyncimage/AsyncImageView.java +++ b/android/sdk/src/main/java/com/tencent/mtt/supportui/views/asyncimage/AsyncImageView.java @@ -337,7 +337,7 @@ public void onRequestFail(Throwable throwable, String source) } protected void handleImageRequest(IDrawableTarget resultDrawable, int sourceType, Object requestInfo) { - if (resultDrawable == null) { + if (!hasImage(resultDrawable)) { if (sourceType == SOURCE_TYPE_SRC) { mSourceDrawable = null; if (mDefaultSourceDrawable != null) { @@ -364,6 +364,10 @@ protected void handleImageRequest(IDrawableTarget resultDrawable, int sourceType } } + protected boolean hasImage(IDrawableTarget resultDrawable) { + return resultDrawable != null; + } + protected ContentDrawable generateContentDrawable() { return new ContentDrawable();