improve file deleting from thumbnails view
This commit is contained in:
parent
be54d59bd0
commit
7600fa68b4
2 changed files with 16 additions and 11 deletions
|
@ -671,22 +671,27 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun deleteFiles(fileDirItems: ArrayList<FileDirItem>) {
|
override fun tryDeleteFiles(fileDirItems: ArrayList<FileDirItem>) {
|
||||||
val filtered = fileDirItems.filter { it.path.isImageVideoGif() } as ArrayList
|
val filtered = fileDirItems.filter { it.path.isImageVideoGif() } as ArrayList
|
||||||
deleteFiles(filtered) {
|
deleteFiles(filtered) {
|
||||||
if (!it) {
|
if (!it) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(R.string.unknown_error_occurred)
|
||||||
} else if (mMedia.isEmpty()) {
|
return@deleteFiles
|
||||||
deleteDirectoryIfEmpty()
|
}
|
||||||
deleteDBDirectory()
|
|
||||||
finish()
|
mMedia.removeAll { filtered.map { it.path }.contains(it.path) }
|
||||||
} else {
|
|
||||||
Thread {
|
Thread {
|
||||||
val mediumDao = galleryDB.MediumDao()
|
val mediumDao = galleryDB.MediumDao()
|
||||||
filtered.forEach {
|
filtered.forEach {
|
||||||
mediumDao.deleteMediumPath(it.path)
|
mediumDao.deleteMediumPath(it.path)
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
|
|
||||||
|
if (mMedia.isEmpty()) {
|
||||||
|
deleteDirectoryIfEmpty()
|
||||||
|
deleteDBDirectory()
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
|
|
||||||
media.removeAll(removeMedia)
|
media.removeAll(removeMedia)
|
||||||
listener?.deleteFiles(fileDirItems)
|
listener?.tryDeleteFiles(fileDirItems)
|
||||||
removeSelectedItems()
|
removeSelectedItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
||||||
interface MediaOperationsListener {
|
interface MediaOperationsListener {
|
||||||
fun refreshItems()
|
fun refreshItems()
|
||||||
|
|
||||||
fun deleteFiles(fileDirItems: ArrayList<FileDirItem>)
|
fun tryDeleteFiles(fileDirItems: ArrayList<FileDirItem>)
|
||||||
|
|
||||||
fun selectedPaths(paths: ArrayList<String>)
|
fun selectedPaths(paths: ArrayList<String>)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue