aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-11-19 11:25:25 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-11-19 11:25:25 +0000
commit4904d46cb27b019d08a2be8c9eb3f64c6bc98afe (patch)
treea2442c5fdd26bc8b99111567ae6d53311d53f160 /app/src
parentc21d59e9796800d250d6ec55e6a027933ef2d528 (diff)
downloadinfinity-for-reddit-4904d46cb27b019d08a2be8c9eb3f64c6bc98afe.tar
infinity-for-reddit-4904d46cb27b019d08a2be8c9eb3f64c6bc98afe.tar.gz
infinity-for-reddit-4904d46cb27b019d08a2be8c9eb3f64c6bc98afe.tar.bz2
infinity-for-reddit-4904d46cb27b019d08a2be8c9eb3f64c6bc98afe.tar.lz
infinity-for-reddit-4904d46cb27b019d08a2be8c9eb3f64c6bc98afe.tar.xz
infinity-for-reddit-4904d46cb27b019d08a2be8c9eb3f64c6bc98afe.tar.zst
infinity-for-reddit-4904d46cb27b019d08a2be8c9eb3f64c6bc98afe.zip
Fix crash in GlideImageGetter.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/GlideImageGetter.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/GlideImageGetter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/GlideImageGetter.java
index ee729d96..28ba6dce 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/GlideImageGetter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/GlideImageGetter.java
@@ -58,13 +58,18 @@ public class GlideImageGetter implements Html.ImageGetter {
BitmapDrawablePlaceholder drawable = new BitmapDrawablePlaceholder(textSize);
- Context context = container.get().getContext();
- if (!(context instanceof Activity && (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()))) {
- container.get().post(() -> Glide.with(context)
- .asBitmap()
- .load(source)
- .into(drawable));
- }
+ container.get().post(() -> {
+ TextView textView = container.get();
+ if (textView != null) {
+ Context context = textView.getContext();
+ if (!(context instanceof Activity && (((Activity) context).isFinishing() || ((Activity) context).isDestroyed()))) {
+ Glide.with(context)
+ .asBitmap()
+ .load(source)
+ .into(drawable);
+ }
+ }
+ });
return drawable;
}