mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +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
|
return@handleSAFDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
var foldersToDelete = ArrayList<File>(selectedKeys.size)
|
activity.handleSAFDeleteSdk30Dialog(SAFPath){
|
||||||
selectedDirs.forEach {
|
if (!it) {
|
||||||
if (it.areFavorites() || it.isRecycleBin()) {
|
return@handleSAFDeleteSdk30Dialog
|
||||||
if (it.isRecycleBin()) {
|
}
|
||||||
tryEmptyRecycleBin(false)
|
|
||||||
|
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 {
|
} else {
|
||||||
ensureBackgroundThread {
|
foldersToDelete.add(File(it.path))
|
||||||
activity.mediaDB.clearFavorites()
|
}
|
||||||
activity.favoritesDB.clearFavorites()
|
}
|
||||||
listener?.refreshItems()
|
|
||||||
|
if (foldersToDelete.size == 1) {
|
||||||
|
activity.handleLockedFolderOpening(foldersToDelete.first().absolutePath) { success ->
|
||||||
|
if (success) {
|
||||||
|
listener?.deleteFolders(foldersToDelete)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedKeys.size == 1) {
|
|
||||||
finishActMode()
|
|
||||||
}
|
|
||||||
} else {
|
} 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
|
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) {
|
activity.handleSAFDialog(SAFPath) {
|
||||||
if (!it) {
|
if (!it) {
|
||||||
return@handleSAFDialog
|
return@handleSAFDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
val fileDirItems = ArrayList<FileDirItem>(selectedKeys.size)
|
val sdk30SafPath = selectedPaths.firstOrNull { activity.isAccessibleWithSAFSdk30(it) } ?: getFirstSelectedItemPath() ?: return@handleSAFDialog
|
||||||
val removeMedia = ArrayList<Medium>(selectedKeys.size)
|
activity.handleSAFDeleteSdk30Dialog(sdk30SafPath){
|
||||||
val positions = getSelectedItemPositions()
|
if (!it) {
|
||||||
|
return@handleSAFDeleteSdk30Dialog
|
||||||
|
}
|
||||||
|
|
||||||
getSelectedItems().forEach {
|
val fileDirItems = ArrayList<FileDirItem>(selectedKeys.size)
|
||||||
fileDirItems.add(FileDirItem(it.path, it.name))
|
val removeMedia = ArrayList<Medium>(selectedKeys.size)
|
||||||
removeMedia.add(it)
|
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,
|
fileDirItem: FileDirItem, allowDeleteFolder: Boolean = false, deleteFromDatabase: Boolean,
|
||||||
callback: ((wasSuccess: Boolean) -> Unit)? = null
|
callback: ((wasSuccess: Boolean) -> Unit)? = null
|
||||||
) {
|
) {
|
||||||
deleteFile(fileDirItem, allowDeleteFolder) {
|
deleteFile(fileDirItem, allowDeleteFolder, isDeletingMultipleFiles = false) {
|
||||||
if (deleteFromDatabase) {
|
if (deleteFromDatabase) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
deleteDBPath(fileDirItem.path)
|
deleteDBPath(fileDirItem.path)
|
||||||
|
|
Loading…
Reference in a new issue