diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt index 944dcb0cd..61ea88362 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -28,7 +28,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va val media = context.getFilesFrom("", isPickImage, isPickVideo) val excludedPaths = config.excludedFolders val directories = groupDirectories(media) - val dirs = ArrayList(directories.values.filter { File(it.path).exists() }).filter { !isThisOrParentExcluded(it.path, excludedPaths) } as ArrayList + val dirs = ArrayList(directories.values.filter { File(it.path).exists() }).filter { !shouldFolderBeVisible(it.path, excludedPaths) } as ArrayList Directory.sorting = config.directorySorting dirs.sort() return movePinnedToFront(dirs) @@ -69,6 +69,10 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va return directories } + private fun shouldFolderBeVisible(path: String, excludedPaths: MutableSet): Boolean { + return isThisOrParentExcluded(path, excludedPaths) || (!config.shouldShowHidden && File(path).containsNoMedia()) + } + private fun isThisOrParentExcluded(path: String, excludedPaths: MutableSet) = excludedPaths.any { path.startsWith(it) } private fun movePinnedToFront(dirs: ArrayList): ArrayList {