fix #1313, delete only the visible files at deleting folders

This commit is contained in:
tibbi 2019-03-05 21:13:31 +01:00
parent 81584a69b4
commit 9ca6f2235b
1 changed files with 20 additions and 17 deletions

View File

@ -500,8 +500,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
}
}
if (config.useRecycleBin) {
val pathsToDelete = ArrayList<String>()
val itemsToDelete = ArrayList<FileDirItem>()
val filter = config.filterMedia
val showHidden = config.shouldShowHidden
fileDirItems.filter { it.isDirectory }.forEach {
@ -513,23 +512,27 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
(it.isGif() && filter and TYPE_GIFS != 0) ||
(it.isRawFast() && filter and TYPE_RAWS != 0) ||
(it.isSvg() && filter and TYPE_SVGS != 0))
}?.mapTo(pathsToDelete) { it.absolutePath }
}?.mapTo(itemsToDelete) { it.toFileDirItem(this) }
}
if (config.useRecycleBin) {
val pathsToDelete = ArrayList<String>()
itemsToDelete.mapTo(pathsToDelete) { it.path }
movePathsInRecycleBin(pathsToDelete, mMediumDao) {
if (it) {
deleteFilteredFolders(fileDirItems, folders)
deleteFilteredFileDirItems(itemsToDelete, folders)
} else {
toast(R.string.unknown_error_occurred)
}
}
} else {
deleteFilteredFolders(fileDirItems, folders)
deleteFilteredFileDirItems(itemsToDelete, folders)
}
}
private fun deleteFilteredFolders(fileDirItems: ArrayList<FileDirItem>, folders: ArrayList<File>) {
deleteFolders(fileDirItems) {
private fun deleteFilteredFileDirItems(fileDirItems: ArrayList<FileDirItem>, folders: ArrayList<File>) {
deleteFiles(fileDirItems) {
runOnUiThread {
refreshItems()
}