mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-18 06:17:59 +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) {
|
if (select) {
|
||||||
itemViews[pos]?.dir_check?.background?.setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN)
|
itemViews[pos]?.dir_check?.background?.setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN)
|
||||||
selectedPositions.add(pos)
|
selectedPositions.add(pos)
|
||||||
} else
|
} else {
|
||||||
selectedPositions.remove(pos)
|
selectedPositions.remove(pos)
|
||||||
|
}
|
||||||
|
|
||||||
itemViews[pos]?.dir_check?.beVisibleIf(select)
|
itemViews[pos]?.dir_check?.beVisibleIf(select)
|
||||||
|
|
||||||
|
@ -258,7 +259,6 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
private fun askConfirmDelete() {
|
private fun askConfirmDelete() {
|
||||||
ConfirmationDialog(activity) {
|
ConfirmationDialog(activity) {
|
||||||
deleteFiles()
|
deleteFiles()
|
||||||
actMode?.finish()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,6 +297,7 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
|
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
|
||||||
|
|
||||||
itemViews = newItems
|
itemViews = newItems
|
||||||
|
actMode?.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,9 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
if (select) {
|
if (select) {
|
||||||
itemViews[pos]?.medium_check?.background?.setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN)
|
itemViews[pos]?.medium_check?.background?.setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN)
|
||||||
selectedPositions.add(pos)
|
selectedPositions.add(pos)
|
||||||
} else
|
} else {
|
||||||
selectedPositions.remove(pos)
|
selectedPositions.remove(pos)
|
||||||
|
}
|
||||||
|
|
||||||
itemViews[pos]?.medium_check?.beVisibleIf(select)
|
itemViews[pos]?.medium_check?.beVisibleIf(select)
|
||||||
|
|
||||||
|
@ -118,11 +119,12 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
var hiddenCnt = 0
|
var hiddenCnt = 0
|
||||||
var unhiddenCnt = 0
|
var unhiddenCnt = 0
|
||||||
selectedPositions.mapNotNull { media.getOrNull(it) }.forEach {
|
selectedPositions.mapNotNull { media.getOrNull(it) }.forEach {
|
||||||
if (it.name.startsWith('.'))
|
if (it.name.startsWith('.')) {
|
||||||
hiddenCnt++
|
hiddenCnt++
|
||||||
else
|
} else {
|
||||||
unhiddenCnt++
|
unhiddenCnt++
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
menu.findItem(R.id.cab_hide).isVisible = unhiddenCnt > 0
|
menu.findItem(R.id.cab_hide).isVisible = unhiddenCnt > 0
|
||||||
menu.findItem(R.id.cab_unhide).isVisible = hiddenCnt > 0
|
menu.findItem(R.id.cab_unhide).isVisible = hiddenCnt > 0
|
||||||
|
@ -205,15 +207,15 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
private fun askConfirmDelete() {
|
private fun askConfirmDelete() {
|
||||||
ConfirmationDialog(activity) {
|
ConfirmationDialog(activity) {
|
||||||
deleteFiles()
|
deleteFiles()
|
||||||
actMode?.finish()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCurrentFile() = File(media[selectedPositions.first()].path)
|
private fun getCurrentFile() = File(media[selectedPositions.first()].path)
|
||||||
|
|
||||||
private fun deleteFiles() {
|
private fun deleteFiles() {
|
||||||
if (selectedPositions.isEmpty())
|
if (selectedPositions.isEmpty()) {
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val files = ArrayList<File>(selectedPositions.size)
|
val files = ArrayList<File>(selectedPositions.size)
|
||||||
val removeMedia = ArrayList<Medium>(selectedPositions.size)
|
val removeMedia = ArrayList<Medium>(selectedPositions.size)
|
||||||
|
|
Loading…
Reference in a new issue