mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 06:28:00 +01:00
fix media store crash on deletion on android 12
- MediaStore crashed on deletion because the ViewPagerActivity got finish before the MediaStore.createDeleteRequest executes - To fix, we apply the same approach in the MediaActivity and finish explicitly after deletion completes, if the media list is empty - also, only refresh the UI when the media list is not empty to avoid UI glitches - fix slideshow bug by resetting mAreSlideShowMediaVisible back to false when the slideshow ends
This commit is contained in:
parent
b3ad40739f
commit
3571fcd3ab
1 changed files with 23 additions and 8 deletions
|
@ -591,6 +591,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
showSystemUI(true)
|
showSystemUI(true)
|
||||||
mSlideshowHandler.removeCallbacksAndMessages(null)
|
mSlideshowHandler.removeCallbacksAndMessages(null)
|
||||||
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
mAreSlideShowMediaVisible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1128,16 +1129,21 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
mIgnoredPaths.add(fileDirItem.path)
|
mIgnoredPaths.add(fileDirItem.path)
|
||||||
val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<ThumbnailItem>
|
val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<Medium>
|
||||||
runOnUiThread {
|
if (media.isNotEmpty()) {
|
||||||
gotMedia(media, true, false)
|
runOnUiThread {
|
||||||
|
refreshUI(media, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
movePathsInRecycleBin(arrayListOf(path)) {
|
movePathsInRecycleBin(arrayListOf(path)) {
|
||||||
if (it) {
|
if (it) {
|
||||||
tryDeleteFileDirItem(fileDirItem, false, false) {
|
tryDeleteFileDirItem(fileDirItem, false, false) {
|
||||||
mIgnoredPaths.remove(fileDirItem.path)
|
mIgnoredPaths.remove(fileDirItem.path)
|
||||||
deleteDirectoryIfEmpty()
|
if (media.isEmpty()) {
|
||||||
|
deleteDirectoryIfEmpty()
|
||||||
|
finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(R.string.unknown_error_occurred)
|
||||||
|
@ -1156,14 +1162,19 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
mIgnoredPaths.add(fileDirItem.path)
|
mIgnoredPaths.add(fileDirItem.path)
|
||||||
val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<ThumbnailItem>
|
val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<Medium>
|
||||||
runOnUiThread {
|
if (media.isNotEmpty()) {
|
||||||
gotMedia(media, true, false)
|
runOnUiThread {
|
||||||
|
refreshUI(media, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tryDeleteFileDirItem(fileDirItem, false, true) {
|
tryDeleteFileDirItem(fileDirItem, false, true) {
|
||||||
mIgnoredPaths.remove(fileDirItem.path)
|
mIgnoredPaths.remove(fileDirItem.path)
|
||||||
deleteDirectoryIfEmpty()
|
if (media.isEmpty()) {
|
||||||
|
deleteDirectoryIfEmpty()
|
||||||
|
finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1227,6 +1238,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshUI(media, refetchViewPagerPosition)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun refreshUI(media: ArrayList<Medium>, refetchViewPagerPosition: Boolean) {
|
||||||
mPrevHashcode = media.hashCode()
|
mPrevHashcode = media.hashCode()
|
||||||
mMediaFiles = media
|
mMediaFiles = media
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue