From 9e7350da162e8e4e66a37bad063b96c65f427ac7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 4 May 2020 15:36:27 +0200 Subject: [PATCH] do not add the excluded folders into everShownFolders --- .../gallery/pro/activities/MainActivity.kt | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index ebc2f1f5a..99d8b4f5d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -1056,21 +1056,30 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { directories_refresh_layout.isRefreshing = false checkPlaceholderVisibility(dirs) } - checkInvalidDirectories(dirs) - val everShownFolders = config.everShownFolders as HashSet - dirs.mapTo(everShownFolders) { it.path } + checkInvalidDirectories(dirs) + if (mDirs.size > 50) { + excludeSpamFolders() + } + + val excludedFolders = config.excludedFolders + val everShownFolders = HashSet() + + // do not add excluded folders and their subfolders at everShownFolders + dirs.filter { dir -> + if (excludedFolders.any { dir.path.startsWith(it) }) { + return@filter false + } + return@filter true + }.mapTo(everShownFolders) { it.path } try { + // catch some extreme exceptions like too many everShownFolders for storing, shouldnt really happen config.everShownFolders = everShownFolders } catch (e: Exception) { config.everShownFolders = HashSet() } mDirs = dirs.clone() as ArrayList - - if (mDirs.size > 55) { - excludeSpamFolders() - } } private fun checkPlaceholderVisibility(dirs: ArrayList) {