Merge pull request #2357 from KryptKode/ref/delete-animation

fix: show delete animation after file delete
This commit is contained in:
Tibor Kaputa 2022-02-25 23:06:27 +01:00 committed by GitHub
commit fb58d0b9a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 39 deletions

View file

@ -626,6 +626,11 @@ class DirectoryAdapter(
return@handleSAFDialog return@handleSAFDialog
} }
activity.handleSAFDeleteSdk30Dialog(SAFPath){
if (!it) {
return@handleSAFDeleteSdk30Dialog
}
var foldersToDelete = ArrayList<File>(selectedKeys.size) var foldersToDelete = ArrayList<File>(selectedKeys.size)
selectedDirs.forEach { selectedDirs.forEach {
if (it.areFavorites() || it.isRecycleBin()) { if (it.areFavorites() || it.isRecycleBin()) {
@ -659,6 +664,7 @@ class DirectoryAdapter(
} }
} }
} }
}
private fun tryChangeAlbumCover(useDefault: Boolean) { private fun tryChangeAlbumCover(useDefault: Boolean) {
activity.handleLockedFolderOpening(getFirstSelectedItemPath() ?: "") { success -> activity.handleLockedFolderOpening(getFirstSelectedItemPath() ?: "") { success ->

View file

@ -459,17 +459,25 @@ 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 sdk30SafPath = selectedPaths.firstOrNull { activity.isAccessibleWithSAFSdk30(it) } ?: getFirstSelectedItemPath() ?: return@handleSAFDialog
activity.handleSAFDeleteSdk30Dialog(sdk30SafPath){
if (!it) {
return@handleSAFDeleteSdk30Dialog
}
val fileDirItems = ArrayList<FileDirItem>(selectedKeys.size) val fileDirItems = ArrayList<FileDirItem>(selectedKeys.size)
val removeMedia = ArrayList<Medium>(selectedKeys.size) val removeMedia = ArrayList<Medium>(selectedKeys.size)
val positions = getSelectedItemPositions() val positions = getSelectedItemPositions()
getSelectedItems().forEach { selectedItems.forEach {
fileDirItems.add(FileDirItem(it.path, it.name)) fileDirItems.add(FileDirItem(it.path, it.name))
removeMedia.add(it) removeMedia.add(it)
} }
@ -481,6 +489,7 @@ class MediaAdapter(
currentMediaHash = media.hashCode() currentMediaHash = media.hashCode()
} }
} }
}
private fun getSelectedItems() = selectedKeys.mapNotNull { getItemWithKey(it) } as ArrayList<Medium> private fun getSelectedItems() = selectedKeys.mapNotNull { getItemWithKey(it) } as ArrayList<Medium>

View file

@ -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)