add handling for moving whole folders in the recycle bin

This commit is contained in:
tibbi 2018-06-27 15:20:22 +02:00
parent f852b69f6e
commit 59cb293d98

View file

@ -395,6 +395,26 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
override fun deleteFolders(folders: ArrayList<File>) {
val fileDirItems = folders.map { FileDirItem(it.absolutePath, it.name, true) } as ArrayList<FileDirItem>
if (config.useRecycleBin) {
val pathsToDelete = ArrayList<String>()
fileDirItems.filter { it.isDirectory }.forEach {
val files = File(it.path).listFiles()
files?.filter { it.absolutePath.isImageVideoGif() }?.mapTo(pathsToDelete) { it.absolutePath }
}
movePathsInRecycleBin(pathsToDelete) {
if (it) {
deleteFilteredFolders(fileDirItems, folders)
} else {
toast(R.string.unknown_error_occurred)
}
}
} else {
deleteFilteredFolders(fileDirItems, folders)
}
}
private fun deleteFilteredFolders(fileDirItems: ArrayList<FileDirItem>, folders: ArrayList<File>) {
deleteFolders(fileDirItems) {
runOnUiThread {
refreshItems()