mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 06:28:00 +01:00
Merge pull request #2464 from KryptKode/fix/android_12_mediastore_crash
fix media store crash on deletion on android 12
This commit is contained in:
commit
2e4d605940
1 changed files with 23 additions and 8 deletions
|
@ -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<ThumbnailItem>
|
||||
val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<Medium>
|
||||
if (media.isNotEmpty()) {
|
||||
runOnUiThread {
|
||||
gotMedia(media, true, false)
|
||||
refreshUI(media, true)
|
||||
}
|
||||
}
|
||||
|
||||
movePathsInRecycleBin(arrayListOf(path)) {
|
||||
if (it) {
|
||||
tryDeleteFileDirItem(fileDirItem, false, false) {
|
||||
mIgnoredPaths.remove(fileDirItem.path)
|
||||
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<ThumbnailItem>
|
||||
val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<Medium>
|
||||
if (media.isNotEmpty()) {
|
||||
runOnUiThread {
|
||||
gotMedia(media, true, false)
|
||||
refreshUI(media, true)
|
||||
}
|
||||
}
|
||||
|
||||
tryDeleteFileDirItem(fileDirItem, false, true) {
|
||||
mIgnoredPaths.remove(fileDirItem.path)
|
||||
if (media.isEmpty()) {
|
||||
deleteDirectoryIfEmpty()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1231,6 +1242,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
return
|
||||
}
|
||||
|
||||
refreshUI(media, refetchViewPagerPosition)
|
||||
}
|
||||
|
||||
private fun refreshUI(media: ArrayList<Medium>, refetchViewPagerPosition: Boolean) {
|
||||
mPrevHashcode = media.hashCode()
|
||||
mMediaFiles = media
|
||||
|
||||
|
|
Loading…
Reference in a new issue