From 77f3c3adb670d32f4c3757bf57a25056ba3e1640 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 27 Sep 2019 15:26:58 +0200 Subject: [PATCH] split directories at media fetching into a separate arraylist --- .../gallery/pro/helpers/MediaFetcher.kt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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) {