aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml/docilealligator/infinityforreddit
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-04-18 03:34:43 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-04-18 03:34:43 +0000
commitbde2220d91774337fba60cfdcc4324005b878736 (patch)
treeceeedce993984fadf5631d92c5c5d95885abb8b5 /app/src/main/java/ml/docilealligator/infinityforreddit
parent372acf4cf45a0420998cba31683b3e66844d3a1e (diff)
downloadinfinity-for-reddit-bde2220d91774337fba60cfdcc4324005b878736.tar
infinity-for-reddit-bde2220d91774337fba60cfdcc4324005b878736.tar.gz
infinity-for-reddit-bde2220d91774337fba60cfdcc4324005b878736.tar.bz2
infinity-for-reddit-bde2220d91774337fba60cfdcc4324005b878736.tar.lz
infinity-for-reddit-bde2220d91774337fba60cfdcc4324005b878736.tar.xz
infinity-for-reddit-bde2220d91774337fba60cfdcc4324005b878736.tar.zst
infinity-for-reddit-bde2220d91774337fba60cfdcc4324005b878736.zip
Remove unused attributes. Fix loading images using GlideImageGetter after the activity is destroyed.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java13
1 files changed, 9 insertions, 4 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 8e018449..04c16284 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/GlideImageGetter.java
@@ -1,5 +1,7 @@
package ml.docilealligator.infinityforreddit.Utils;
+import android.app.Activity;
+import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
@@ -53,10 +55,13 @@ public class GlideImageGetter implements Html.ImageGetter {
BitmapDrawablePlaceholder drawable = new BitmapDrawablePlaceholder(textSize);
- container.get().post(() -> Glide.with(container.get().getContext())
- .asBitmap()
- .load(source)
- .into(drawable));
+ Context context = container.get().getContext();
+ if (!(context instanceof Activity && ((Activity) context).isFinishing())) {
+ container.get().post(() -> Glide.with(context)
+ .asBitmap()
+ .load(source)
+ .into(drawable));
+ }
return drawable;
}