diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index b61f08f97..a2c193d49 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -899,7 +899,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { try { for (directory in dirs) { - if (mShouldStopFetching) { + if (mShouldStopFetching || isDestroyed || isFinishing) { return } @@ -972,7 +972,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { // check the remaining folders which were not cached at all yet for (folder in foldersToScan) { - if (mShouldStopFetching) { + if (mShouldStopFetching || isDestroyed || isFinishing) { return }