mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
Merge pull request #2357 from KryptKode/ref/delete-animation
fix: show delete animation after file delete
This commit is contained in:
commit
fb58d0b9a5
3 changed files with 54 additions and 39 deletions
|
@ -626,37 +626,43 @@ class DirectoryAdapter(
|
|||
return@handleSAFDialog
|
||||
}
|
||||
|
||||
var foldersToDelete = ArrayList<File>(selectedKeys.size)
|
||||
selectedDirs.forEach {
|
||||
if (it.areFavorites() || it.isRecycleBin()) {
|
||||
if (it.isRecycleBin()) {
|
||||
tryEmptyRecycleBin(false)
|
||||
activity.handleSAFDeleteSdk30Dialog(SAFPath){
|
||||
if (!it) {
|
||||
return@handleSAFDeleteSdk30Dialog
|
||||
}
|
||||
|
||||
var foldersToDelete = ArrayList<File>(selectedKeys.size)
|
||||
selectedDirs.forEach {
|
||||
if (it.areFavorites() || it.isRecycleBin()) {
|
||||
if (it.isRecycleBin()) {
|
||||
tryEmptyRecycleBin(false)
|
||||
} else {
|
||||
ensureBackgroundThread {
|
||||
activity.mediaDB.clearFavorites()
|
||||
activity.favoritesDB.clearFavorites()
|
||||
listener?.refreshItems()
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedKeys.size == 1) {
|
||||
finishActMode()
|
||||
}
|
||||
} else {
|
||||
ensureBackgroundThread {
|
||||
activity.mediaDB.clearFavorites()
|
||||
activity.favoritesDB.clearFavorites()
|
||||
listener?.refreshItems()
|
||||
foldersToDelete.add(File(it.path))
|
||||
}
|
||||
}
|
||||
|
||||
if (foldersToDelete.size == 1) {
|
||||
activity.handleLockedFolderOpening(foldersToDelete.first().absolutePath) { success ->
|
||||
if (success) {
|
||||
listener?.deleteFolders(foldersToDelete)
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedKeys.size == 1) {
|
||||
finishActMode()
|
||||
}
|
||||
} else {
|
||||
foldersToDelete.add(File(it.path))
|
||||
foldersToDelete = foldersToDelete.filter { !config.isFolderProtected(it.absolutePath) }.toMutableList() as ArrayList<File>
|
||||
listener?.deleteFolders(foldersToDelete)
|
||||
}
|
||||
}
|
||||
|
||||
if (foldersToDelete.size == 1) {
|
||||
activity.handleLockedFolderOpening(foldersToDelete.first().absolutePath) { success ->
|
||||
if (success) {
|
||||
listener?.deleteFolders(foldersToDelete)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foldersToDelete = foldersToDelete.filter { !config.isFolderProtected(it.absolutePath) }.toMutableList() as ArrayList<File>
|
||||
listener?.deleteFolders(foldersToDelete)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -459,26 +459,35 @@ class MediaAdapter(
|
|||
return
|
||||
}
|
||||
|
||||
val SAFPath = getSelectedPaths().firstOrNull { activity.needsStupidWritePermissions(it) } ?: getFirstSelectedItemPath() ?: return
|
||||
val selectedItems = getSelectedItems()
|
||||
val selectedPaths = selectedItems.map { it.path } as ArrayList<String>
|
||||
val SAFPath = selectedPaths.firstOrNull { activity.needsStupidWritePermissions(it) } ?: getFirstSelectedItemPath() ?: return
|
||||
activity.handleSAFDialog(SAFPath) {
|
||||
if (!it) {
|
||||
return@handleSAFDialog
|
||||
}
|
||||
|
||||
val fileDirItems = ArrayList<FileDirItem>(selectedKeys.size)
|
||||
val removeMedia = ArrayList<Medium>(selectedKeys.size)
|
||||
val positions = getSelectedItemPositions()
|
||||
val sdk30SafPath = selectedPaths.firstOrNull { activity.isAccessibleWithSAFSdk30(it) } ?: getFirstSelectedItemPath() ?: return@handleSAFDialog
|
||||
activity.handleSAFDeleteSdk30Dialog(sdk30SafPath){
|
||||
if (!it) {
|
||||
return@handleSAFDeleteSdk30Dialog
|
||||
}
|
||||
|
||||
getSelectedItems().forEach {
|
||||
fileDirItems.add(FileDirItem(it.path, it.name))
|
||||
removeMedia.add(it)
|
||||
val fileDirItems = ArrayList<FileDirItem>(selectedKeys.size)
|
||||
val removeMedia = ArrayList<Medium>(selectedKeys.size)
|
||||
val positions = getSelectedItemPositions()
|
||||
|
||||
selectedItems.forEach {
|
||||
fileDirItems.add(FileDirItem(it.path, it.name))
|
||||
removeMedia.add(it)
|
||||
}
|
||||
|
||||
media.removeAll(removeMedia)
|
||||
listener?.tryDeleteFiles(fileDirItems)
|
||||
listener?.updateMediaGridDecoration(media)
|
||||
removeSelectedItems(positions)
|
||||
currentMediaHash = media.hashCode()
|
||||
}
|
||||
|
||||
media.removeAll(removeMedia)
|
||||
listener?.tryDeleteFiles(fileDirItems)
|
||||
listener?.updateMediaGridDecoration(media)
|
||||
removeSelectedItems(positions)
|
||||
currentMediaHash = media.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ fun BaseSimpleActivity.tryDeleteFileDirItem(
|
|||
fileDirItem: FileDirItem, allowDeleteFolder: Boolean = false, deleteFromDatabase: Boolean,
|
||||
callback: ((wasSuccess: Boolean) -> Unit)? = null
|
||||
) {
|
||||
deleteFile(fileDirItem, allowDeleteFolder) {
|
||||
deleteFile(fileDirItem, allowDeleteFolder, isDeletingMultipleFiles = false) {
|
||||
if (deleteFromDatabase) {
|
||||
ensureBackgroundThread {
|
||||
deleteDBPath(fileDirItem.path)
|
||||
|
|
Loading…
Reference in a new issue