From 6aecf9e3c2a9a3c7e7bf54448ece49cb9b324990 Mon Sep 17 00:00:00 2001 From: PhotonQyv Date: Sun, 17 Dec 2017 01:08:09 +0000 Subject: [PATCH] Added code to hopefully fix a crash caused by passing a destroyed context into the Glide library. --- .../main/java/fr/gouv/etalab/mastodon/helper/Helper.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index 4868d461c..86a1e6054 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -28,6 +28,7 @@ import android.graphics.Rect; import android.graphics.RectF; import android.os.CountDownTimer; import android.support.annotation.Nullable; +import android.support.v4.app.FragmentActivity; import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.app.AlertDialog; import android.app.DownloadManager; @@ -1743,6 +1744,14 @@ public class Helper { SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); boolean disableGif = sharedpreferences.getBoolean(SET_DISABLE_GIF, false); + if (context instanceof FragmentActivity) { + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && ((FragmentActivity) context).isDestroyed()) + { + return; + } + } + if( !disableGif) Glide.with(imageView.getContext()) .load(url)