mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-17 22:08:00 +01:00
do not finish the actionmode right after a delete attempt, because of saf
This commit is contained in:
parent
1d56b2ac8b
commit
5441457611
2 changed files with 10 additions and 7 deletions
|
@ -46,8 +46,9 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
if (select) {
|
||||
itemViews[pos]?.dir_check?.background?.setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN)
|
||||
selectedPositions.add(pos)
|
||||
} else
|
||||
} else {
|
||||
selectedPositions.remove(pos)
|
||||
}
|
||||
|
||||
itemViews[pos]?.dir_check?.beVisibleIf(select)
|
||||
|
||||
|
@ -258,7 +259,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
private fun askConfirmDelete() {
|
||||
ConfirmationDialog(activity) {
|
||||
deleteFiles()
|
||||
actMode?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,6 +297,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
|||
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
|
||||
|
||||
itemViews = newItems
|
||||
actMode?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,9 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
if (select) {
|
||||
itemViews[pos]?.medium_check?.background?.setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN)
|
||||
selectedPositions.add(pos)
|
||||
} else
|
||||
} else {
|
||||
selectedPositions.remove(pos)
|
||||
}
|
||||
|
||||
itemViews[pos]?.medium_check?.beVisibleIf(select)
|
||||
|
||||
|
@ -118,10 +119,11 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
var hiddenCnt = 0
|
||||
var unhiddenCnt = 0
|
||||
selectedPositions.mapNotNull { media.getOrNull(it) }.forEach {
|
||||
if (it.name.startsWith('.'))
|
||||
if (it.name.startsWith('.')) {
|
||||
hiddenCnt++
|
||||
else
|
||||
} else {
|
||||
unhiddenCnt++
|
||||
}
|
||||
}
|
||||
|
||||
menu.findItem(R.id.cab_hide).isVisible = unhiddenCnt > 0
|
||||
|
@ -205,15 +207,15 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
private fun askConfirmDelete() {
|
||||
ConfirmationDialog(activity) {
|
||||
deleteFiles()
|
||||
actMode?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCurrentFile() = File(media[selectedPositions.first()].path)
|
||||
|
||||
private fun deleteFiles() {
|
||||
if (selectedPositions.isEmpty())
|
||||
if (selectedPositions.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
val files = ArrayList<File>(selectedPositions.size)
|
||||
val removeMedia = ArrayList<Medium>(selectedPositions.size)
|
||||
|
|
Loading…
Reference in a new issue