mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-12-03 17:57:59 +01:00
visually speed up file deletion from fullscreen view by storing ignored paths
This commit is contained in:
parent
594c198cf2
commit
1e697e75d6
1 changed files with 13 additions and 7 deletions
|
@ -70,6 +70,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
private var mMediaFiles = ArrayList<Medium>()
|
private var mMediaFiles = ArrayList<Medium>()
|
||||||
private var mFavoritePaths = ArrayList<String>()
|
private var mFavoritePaths = ArrayList<String>()
|
||||||
|
private var mIgnoredPaths = ArrayList<String>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -908,17 +909,22 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) {
|
if (config.useRecycleBin && !getCurrentMedium()!!.getIsInRecycleBin()) {
|
||||||
movePathsInRecycleBin(arrayListOf(path)) {
|
movePathsInRecycleBin(arrayListOf(path)) {
|
||||||
if (it) {
|
if (it) {
|
||||||
tryDeleteFileDirItem(fileDirItem, false, false) {
|
handleDeletion(fileDirItem, false)
|
||||||
refreshViewPager()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tryDeleteFileDirItem(fileDirItem, false, true) {
|
handleDeletion(fileDirItem, true)
|
||||||
refreshViewPager()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleDeletion(fileDirItem: FileDirItem, deleteFromDatabase: Boolean) {
|
||||||
|
mIgnoredPaths.add(fileDirItem.path)
|
||||||
|
val media = mMediaFiles.filter { !mIgnoredPaths.contains(it.path) } as ArrayList<ThumbnailItem>
|
||||||
|
gotMedia(media)
|
||||||
|
tryDeleteFileDirItem(fileDirItem, false, deleteFromDatabase) {
|
||||||
|
mIgnoredPaths.remove(fileDirItem.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,7 +967,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun gotMedia(thumbnailItems: ArrayList<ThumbnailItem>) {
|
private fun gotMedia(thumbnailItems: ArrayList<ThumbnailItem>) {
|
||||||
val media = thumbnailItems.asSequence().filter { it is Medium }.map { it as Medium }.toMutableList() as ArrayList<Medium>
|
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) {
|
if (isDirEmpty(media) || media.hashCode() == mPrevHashcode) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue