adding some extra checks at deleting files and folders
This commit is contained in:
parent
e86c07895c
commit
bdaec15293
3 changed files with 11 additions and 4 deletions
|
@ -420,9 +420,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun deleteFolders(folders: ArrayList<File>) {
|
override fun deleteFolders(folders: ArrayList<File>) {
|
||||||
val fileDirItems = folders.map { FileDirItem(it.absolutePath, it.name, true) } as ArrayList<FileDirItem>
|
val fileDirItems = folders.asSequence().filter { it.isDirectory }.map { FileDirItem(it.absolutePath, it.name, true) }.toMutableList() as ArrayList<FileDirItem>
|
||||||
|
if (fileDirItems.isEmpty()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fileDirItems.forEach {
|
fileDirItems.forEach {
|
||||||
toast(String.format(getString(R.string.deleting_folder), it.name), Toast.LENGTH_LONG)
|
toast(String.format(getString(R.string.deleting_folder), it.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.useRecycleBin) {
|
if (config.useRecycleBin) {
|
||||||
|
|
|
@ -832,7 +832,11 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun tryDeleteFiles(fileDirItems: ArrayList<FileDirItem>) {
|
override fun tryDeleteFiles(fileDirItems: ArrayList<FileDirItem>) {
|
||||||
val filtered = fileDirItems.filter { it.path.isMediaFile() } as ArrayList
|
val filtered = fileDirItems.filter { File(it.path).isFile && it.path.isMediaFile() } as ArrayList
|
||||||
|
if (filtered.isEmpty()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
val deletingItems = resources.getQuantityString(R.plurals.deleting_items, filtered.size, filtered.size)
|
val deletingItems = resources.getQuantityString(R.plurals.deleting_items, filtered.size, filtered.size)
|
||||||
toast(deletingItems)
|
toast(deletingItems)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import com.simplemobiletools.gallery.models.ThumbnailItem
|
||||||
import com.simplemobiletools.gallery.models.ThumbnailSection
|
import com.simplemobiletools.gallery.models.ThumbnailSection
|
||||||
import kotlinx.android.synthetic.main.photo_video_item_grid.view.*
|
import kotlinx.android.synthetic.main.photo_video_item_grid.view.*
|
||||||
import kotlinx.android.synthetic.main.thumbnail_section.view.*
|
import kotlinx.android.synthetic.main.thumbnail_section.view.*
|
||||||
import java.lang.Exception
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue