adding some extra checks at deleting files and folders

This commit is contained in:
tibbi 2018-09-20 21:22:45 +02:00
parent e86c07895c
commit bdaec15293
3 changed files with 11 additions and 4 deletions

View file

@ -420,9 +420,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
}
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 {
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) {

View file

@ -832,7 +832,11 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
}
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)
toast(deletingItems)

View file

@ -28,7 +28,6 @@ import com.simplemobiletools.gallery.models.ThumbnailItem
import com.simplemobiletools.gallery.models.ThumbnailSection
import kotlinx.android.synthetic.main.photo_video_item_grid.view.*
import kotlinx.android.synthetic.main.thumbnail_section.view.*
import java.lang.Exception
import java.text.SimpleDateFormat
import java.util.*