fix #1785, properly handle deleting playing videos

This commit is contained in:
tibbi 2020-03-18 21:40:23 +01:00
parent f31d9bafa5
commit 2262829077

View file

@ -1033,7 +1033,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
mIgnoredPaths.add(fileDirItem.path)
val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<ThumbnailItem>
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<ThumbnailItem>
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<ThumbnailItem>) {
private fun gotMedia(thumbnailItems: ArrayList<ThumbnailItem>, ignorePlayingVideos: Boolean = false) {
val media = thumbnailItems.asSequence().filter { it is Medium && !mIgnoredPaths.contains(it.path) }.map { it as Medium }.toMutableList() as ArrayList<Medium>
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
}