diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt index 33621b58f..72d5e07f6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt @@ -207,11 +207,24 @@ class MediaFetcher(val context: Context) { val checkFileExistence = config.fileLoadingPriority == PRIORITY_VALIDITY val showHidden = config.shouldShowHidden val dateTakens = if (getProperDateTaken && folder != FAVORITES && !isRecycleBin) getFolderDateTakens(folder) else HashMap() + val subdirs = ArrayList() val files = when (folder) { - FAVORITES -> favoritePaths.filter { showHidden || !it.contains("/.") }.map { File(it) }.toTypedArray() - RECYCLE_BIN -> deletedMedia.map { File(it.path) }.toTypedArray() - else -> File(folder).listFiles() ?: return media + FAVORITES -> favoritePaths.filter { showHidden || !it.contains("/.") }.map { File(it) }.toMutableList() as ArrayList + RECYCLE_BIN -> deletedMedia.map { File(it.path) }.toMutableList() as ArrayList + else -> { + val allFiles = File(folder).listFiles() ?: return media + val notDirs = ArrayList() + allFiles.forEach { + if (it.isDirectory) { + subdirs.add(it) + } else { + notDirs.add(it) + } + } + + notDirs + } } for (file in files) {