From 566e4ea2b379ebcd17bce4a85cc6ae79e87ded77 Mon Sep 17 00:00:00 2001 From: Guido Arnau Date: Sun, 27 Aug 2017 21:22:26 +0100 Subject: [PATCH] Fixes Crash on Android API 16 (Jelly Bean) Check that the version is greater than API 16 when calling Activity.isDestroyed() --- .../simplemobiletools/gallery/adapters/DirectoryAdapter.kt | 7 +++++-- .../com/simplemobiletools/gallery/adapters/MediaAdapter.kt | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 3ef268ecf..7e7a10d01 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.gallery.adapters import android.graphics.PorterDuff +import android.os.Build import android.support.v7.view.ActionMode import android.support.v7.widget.RecyclerView import android.util.SparseArray @@ -430,8 +431,10 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed) + return + + Glide.with(activity).clear(view.dir_thumbnail) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 9cbe8915e..c0b026892 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.gallery.adapters import android.graphics.PorterDuff +import android.os.Build import android.support.v7.view.ActionMode import android.support.v7.widget.RecyclerView import android.util.SparseArray @@ -347,8 +348,10 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } fun stopLoad() { - if (!activity.isDestroyed) - Glide.with(activity).clear(view.medium_thumbnail) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed) + return + + Glide.with(activity).clear(view.medium_thumbnail) } }