From 22628290770237d358e11dc3ee7a1fa56445b753 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 18 Mar 2020 21:40:23 +0100 Subject: [PATCH] fix #1785, properly handle deleting playing videos --- .../gallery/pro/activities/ViewPagerActivity.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 77dffb031..c770ace40 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 @@ -1033,7 +1033,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View mIgnoredPaths.add(fileDirItem.path) val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList runOnUiThread { - gotMedia(media) + gotMedia(media, true) } movePathsInRecycleBin(arrayListOf(path)) { @@ -1055,7 +1055,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View mIgnoredPaths.add(fileDirItem.path) val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList runOnUiThread { - gotMedia(media) + gotMedia(media, true) } tryDeleteFileDirItem(fileDirItem, false, true) { @@ -1102,9 +1102,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } - private fun gotMedia(thumbnailItems: ArrayList) { + private fun gotMedia(thumbnailItems: ArrayList, ignorePlayingVideos: Boolean = false) { val media = thumbnailItems.asSequence().filter { it is Medium && !mIgnoredPaths.contains(it.path) }.map { it as Medium }.toMutableList() as ArrayList - if (isDirEmpty(media) || media.hashCode() == mPrevHashcode || (getCurrentFragment() as? VideoFragment)?.mIsPlaying == true) { + if (isDirEmpty(media) || media.hashCode() == mPrevHashcode) { + return + } + + if (!ignorePlayingVideos && (getCurrentFragment() as? VideoFragment)?.mIsPlaying == true) { return }