diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 2c5d75b9f..c254ed128 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -595,6 +595,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View showSystemUI(true) mSlideshowHandler.removeCallbacksAndMessages(null) window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + mAreSlideShowMediaVisible = false } } @@ -1132,16 +1133,21 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } mIgnoredPaths.add(fileDirItem.path) - val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList - runOnUiThread { - gotMedia(media, true, false) + val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList + if (media.isNotEmpty()) { + runOnUiThread { + refreshUI(media, true) + } } movePathsInRecycleBin(arrayListOf(path)) { if (it) { tryDeleteFileDirItem(fileDirItem, false, false) { mIgnoredPaths.remove(fileDirItem.path) - deleteDirectoryIfEmpty() + if (media.isEmpty()) { + deleteDirectoryIfEmpty() + finish() + } } } else { toast(R.string.unknown_error_occurred) @@ -1160,14 +1166,19 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } mIgnoredPaths.add(fileDirItem.path) - val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList - runOnUiThread { - gotMedia(media, true, false) + val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList + if (media.isNotEmpty()) { + runOnUiThread { + refreshUI(media, true) + } } tryDeleteFileDirItem(fileDirItem, false, true) { mIgnoredPaths.remove(fileDirItem.path) - deleteDirectoryIfEmpty() + if (media.isEmpty()) { + deleteDirectoryIfEmpty() + finish() + } } } } @@ -1231,6 +1242,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View return } + refreshUI(media, refetchViewPagerPosition) + } + + private fun refreshUI(media: ArrayList, refetchViewPagerPosition: Boolean) { mPrevHashcode = media.hashCode() mMediaFiles = media