diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index a9f0eb0b4..c13654404 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -559,9 +559,15 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } private fun deleteDirectoryIfEmpty() { - val fileDirItem = FileDirItem(mPath, mPath.getFilenameFromPath(), true) - if (config.deleteEmptyFolders && !fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory && fileDirItem.getProperFileCount(this, true) == 0) { - tryDeleteFileDirItem(fileDirItem, true, true) + if (config.deleteEmptyFolders) { + val fileDirItem = FileDirItem(mPath, mPath.getFilenameFromPath(), true) + if (!fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory) { + ensureBackgroundThread { + if (fileDirItem.getProperFileCount(this, true) == 0) { + tryDeleteFileDirItem(fileDirItem, true, true) + } + } + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 0ba0fcb63..b01727673 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -1163,12 +1163,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } private fun deleteDirectoryIfEmpty() { - val fileDirItem = FileDirItem(mDirectory, mDirectory.getFilenameFromPath(), File(mDirectory).isDirectory) - if (config.deleteEmptyFolders && !fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory) { - ensureBackgroundThread { - if (fileDirItem.getProperFileCount(this, true) == 0) { - tryDeleteFileDirItem(fileDirItem, true, true) - scanPathRecursively(mDirectory) + if (config.deleteEmptyFolders) { + val fileDirItem = FileDirItem(mDirectory, mDirectory.getFilenameFromPath(), File(mDirectory).isDirectory) + if (!fileDirItem.isDownloadsFolder() && fileDirItem.isDirectory) { + ensureBackgroundThread { + if (fileDirItem.getProperFileCount(this, true) == 0) { + tryDeleteFileDirItem(fileDirItem, true, true) + scanPathRecursively(mDirectory) + } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index f75e6c0af..a26639b55 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -158,7 +158,9 @@ fun BaseSimpleActivity.addNoMedia(path: String, callback: () -> Unit) { } else { try { if (file.createNewFile()) { - addNoMediaIntoMediaStore(file.absolutePath) + ensureBackgroundThread { + addNoMediaIntoMediaStore(file.absolutePath) + } } else { toast(R.string.unknown_error_occurred) }