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

View file

@ -459,17 +459,25 @@ 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 sdk30SafPath = selectedPaths.firstOrNull { activity.isAccessibleWithSAFSdk30(it) } ?: getFirstSelectedItemPath() ?: return@handleSAFDialog
activity.handleSAFDeleteSdk30Dialog(sdk30SafPath){
if (!it) {
return@handleSAFDeleteSdk30Dialog
}
val fileDirItems = ArrayList<FileDirItem>(selectedKeys.size)
val removeMedia = ArrayList<Medium>(selectedKeys.size)
val positions = getSelectedItemPositions()
getSelectedItems().forEach {
selectedItems.forEach {
fileDirItems.add(FileDirItem(it.path, it.name))
removeMedia.add(it)
}
@ -481,6 +489,7 @@ class MediaAdapter(
currentMediaHash = media.hashCode()
}
}
}
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,
callback: ((wasSuccess: Boolean) -> Unit)? = null
) {
deleteFile(fileDirItem, allowDeleteFolder) {
deleteFile(fileDirItem, allowDeleteFolder, isDeletingMultipleFiles = false) {
if (deleteFromDatabase) {
ensureBackgroundThread {
deleteDBPath(fileDirItem.path)