fix #1313, delete only the visible files at deleting folders
This commit is contained in:
parent
81584a69b4
commit
9ca6f2235b
1 changed files with 20 additions and 17 deletions
|
@ -500,36 +500,39 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val itemsToDelete = ArrayList<FileDirItem>()
|
||||||
|
val filter = config.filterMedia
|
||||||
|
val showHidden = config.shouldShowHidden
|
||||||
|
fileDirItems.filter { it.isDirectory }.forEach {
|
||||||
|
val files = File(it.path).listFiles()
|
||||||
|
files?.filter {
|
||||||
|
it.absolutePath.isMediaFile() && (showHidden || !it.name.startsWith('.')) &&
|
||||||
|
((it.isImageFast() && filter and TYPE_IMAGES != 0) ||
|
||||||
|
(it.isVideoFast() && filter and TYPE_VIDEOS != 0) ||
|
||||||
|
(it.isGif() && filter and TYPE_GIFS != 0) ||
|
||||||
|
(it.isRawFast() && filter and TYPE_RAWS != 0) ||
|
||||||
|
(it.isSvg() && filter and TYPE_SVGS != 0))
|
||||||
|
}?.mapTo(itemsToDelete) { it.toFileDirItem(this) }
|
||||||
|
}
|
||||||
|
|
||||||
if (config.useRecycleBin) {
|
if (config.useRecycleBin) {
|
||||||
val pathsToDelete = ArrayList<String>()
|
val pathsToDelete = ArrayList<String>()
|
||||||
val filter = config.filterMedia
|
itemsToDelete.mapTo(pathsToDelete) { it.path }
|
||||||
val showHidden = config.shouldShowHidden
|
|
||||||
fileDirItems.filter { it.isDirectory }.forEach {
|
|
||||||
val files = File(it.path).listFiles()
|
|
||||||
files?.filter {
|
|
||||||
it.absolutePath.isMediaFile() && (showHidden || !it.name.startsWith('.')) &&
|
|
||||||
((it.isImageFast() && filter and TYPE_IMAGES != 0) ||
|
|
||||||
(it.isVideoFast() && filter and TYPE_VIDEOS != 0) ||
|
|
||||||
(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 }
|
|
||||||
}
|
|
||||||
|
|
||||||
movePathsInRecycleBin(pathsToDelete, mMediumDao) {
|
movePathsInRecycleBin(pathsToDelete, mMediumDao) {
|
||||||
if (it) {
|
if (it) {
|
||||||
deleteFilteredFolders(fileDirItems, folders)
|
deleteFilteredFileDirItems(itemsToDelete, folders)
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(R.string.unknown_error_occurred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
deleteFilteredFolders(fileDirItems, folders)
|
deleteFilteredFileDirItems(itemsToDelete, folders)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteFilteredFolders(fileDirItems: ArrayList<FileDirItem>, folders: ArrayList<File>) {
|
private fun deleteFilteredFileDirItems(fileDirItems: ArrayList<FileDirItem>, folders: ArrayList<File>) {
|
||||||
deleteFolders(fileDirItems) {
|
deleteFiles(fileDirItems) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
refreshItems()
|
refreshItems()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue