mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-02-17 04:10:39 +01:00
fix #403, delete empty folders after move, if really empty
This commit is contained in:
parent
919d073a03
commit
c8e104d88d
@ -372,17 +372,31 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
|
||||
private fun copyMoveTo(isCopyOperation: Boolean) {
|
||||
val files = getSelectedFileDirItems()
|
||||
val firstFile = files[0]
|
||||
val source = if (firstFile.isDirectory) firstFile.path else firstFile.getParentPath()
|
||||
val source = firstFile.getParentPath()
|
||||
FilePickerDialog(activity, source, false, activity.config.shouldShowHidden, true, true, showFavoritesButton = true) {
|
||||
if (activity.isPathOnRoot(it) || activity.isPathOnRoot(firstFile.path)) {
|
||||
copyMoveRootItems(files, it, isCopyOperation)
|
||||
} else {
|
||||
activity.copyMoveFilesTo(files, source, it, isCopyOperation, false, activity.config.shouldShowHidden) {
|
||||
if (!isCopyOperation) {
|
||||
files.forEach { sourceFileDir ->
|
||||
val sourceFile = File(sourceFileDir.path)
|
||||
if (activity.getDoesFilePathExist(source) && activity.getIsPathDirectory(source) &&
|
||||
sourceFile.list()?.isEmpty() == true && sourceFile.getProperSize(true) == 0L && sourceFile.getFileCount(true) == 0) {
|
||||
val sourceFolder = sourceFile.toFileDirItem(activity)
|
||||
activity.deleteFile(sourceFolder, true) {
|
||||
listener?.refreshItems()
|
||||
finishActMode()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
listener?.refreshItems()
|
||||
finishActMode()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun copyMoveRootItems(files: ArrayList<FileDirItem>, destinationPath: String, isCopyOperation: Boolean) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user