do not add the excluded folders into everShownFolders

This commit is contained in:
tibbi 2020-05-04 15:36:27 +02:00
parent bf600a2fe4
commit 9e7350da16

View file

@ -1056,21 +1056,30 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
directories_refresh_layout.isRefreshing = false directories_refresh_layout.isRefreshing = false
checkPlaceholderVisibility(dirs) checkPlaceholderVisibility(dirs)
} }
checkInvalidDirectories(dirs)
val everShownFolders = config.everShownFolders as HashSet checkInvalidDirectories(dirs)
dirs.mapTo(everShownFolders) { it.path } if (mDirs.size > 50) {
excludeSpamFolders()
}
val excludedFolders = config.excludedFolders
val everShownFolders = HashSet<String>()
// 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 { try {
// catch some extreme exceptions like too many everShownFolders for storing, shouldnt really happen
config.everShownFolders = everShownFolders config.everShownFolders = everShownFolders
} catch (e: Exception) { } catch (e: Exception) {
config.everShownFolders = HashSet() config.everShownFolders = HashSet()
} }
mDirs = dirs.clone() as ArrayList<Directory> mDirs = dirs.clone() as ArrayList<Directory>
if (mDirs.size > 55) {
excludeSpamFolders()
}
} }
private fun checkPlaceholderVisibility(dirs: ArrayList<Directory>) { private fun checkPlaceholderVisibility(dirs: ArrayList<Directory>) {