mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 08:18:00 +01:00
add handling for moving whole folders in the recycle bin
This commit is contained in:
parent
f852b69f6e
commit
59cb293d98
1 changed files with 20 additions and 0 deletions
|
@ -395,6 +395,26 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
|
|
||||||
override fun deleteFolders(folders: ArrayList<File>) {
|
override fun deleteFolders(folders: ArrayList<File>) {
|
||||||
val fileDirItems = folders.map { FileDirItem(it.absolutePath, it.name, true) } as ArrayList<FileDirItem>
|
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) {
|
deleteFolders(fileDirItems) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
refreshItems()
|
refreshItems()
|
||||||
|
|
Loading…
Reference in a new issue