diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 88d74f3da..29e220b8a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -420,9 +420,13 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } override fun deleteFolders(folders: ArrayList) { - val fileDirItems = folders.map { FileDirItem(it.absolutePath, it.name, true) } as ArrayList + val fileDirItems = folders.asSequence().filter { it.isDirectory }.map { FileDirItem(it.absolutePath, it.name, true) }.toMutableList() as ArrayList + 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) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 5107c3d21..5cb161a06 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -832,7 +832,11 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } override fun tryDeleteFiles(fileDirItems: ArrayList) { - 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) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 22ecca74d..6ff454a58 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -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.*