mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
update the deletefiles function with stdlib
This commit is contained in:
@ -199,23 +199,22 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun deleteFiles(files: ArrayList<File>) {
|
override fun deleteFiles(files: ArrayList<File>) {
|
||||||
for (file in files) {
|
files.filter { it.exists() && it.isImageVideoGif() }
|
||||||
if (file.exists() && file.isImageVideoGif()) {
|
.forEach {
|
||||||
if (needsStupidWritePermissions(file.absolutePath)) {
|
if (needsStupidWritePermissions(it.absolutePath)) {
|
||||||
if (isShowingPermDialog(file))
|
if (isShowingPermDialog(it))
|
||||||
return
|
return
|
||||||
|
|
||||||
val document = getFileDocument(file.absolutePath, mConfig.treeUri)
|
val document = getFileDocument(it.absolutePath, mConfig.treeUri)
|
||||||
|
|
||||||
// double check we have the uri to the proper file path, not some parent folder
|
// double check we have the uri to the proper file path, not some parent folder
|
||||||
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory) {
|
if (document.uri.toString().endsWith(it.absolutePath.getFilenameFromPath()) && !document.isDirectory) {
|
||||||
document.delete()
|
document.delete()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
it.delete()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
file.delete()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scanFiles(files) {
|
scanFiles(files) {
|
||||||
if (mMedia.isEmpty()) {
|
if (mMedia.isEmpty()) {
|
||||||
|
Reference in New Issue
Block a user