From e59c061972107afab7b80fbc2949007c1e3d5a1e Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 18 Jan 2021 12:17:44 +0100 Subject: [PATCH] avoid checking cached folders hidden status unnecessarily --- .../gallery/pro/extensions/Context.kt | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index a0250270a..4650b2b90 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -575,19 +575,21 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: } }) as ArrayList - val hiddenString = resources.getString(R.string.hidden) - filteredDirectories.forEach { - val noMediaPath = "${it.path}/.nomedia" - val hasNoMedia = if (folderNoMediaStatuses.keys.contains(noMediaPath)) { - folderNoMediaStatuses[noMediaPath]!! - } else { - it.path.doesThisOrParentHaveNoMedia(noMediaFolders) - } + if (shouldShowHidden) { + val hiddenString = resources.getString(R.string.hidden) + filteredDirectories.forEach { + val noMediaPath = "${it.path}/.nomedia" + val hasNoMedia = if (folderNoMediaStatuses.keys.contains(noMediaPath)) { + folderNoMediaStatuses[noMediaPath]!! + } else { + it.path.doesThisOrParentHaveNoMedia(noMediaFolders) + } - it.name = if (hasNoMedia && !it.path.isThisOrParentIncluded(includedPaths)) { - "${it.name.removeSuffix(hiddenString).trim()} $hiddenString" - } else { - it.name.removeSuffix(hiddenString).trim() + it.name = if (hasNoMedia && !it.path.isThisOrParentIncluded(includedPaths)) { + "${it.name.removeSuffix(hiddenString).trim()} $hiddenString" + } else { + it.name.removeSuffix(hiddenString).trim() + } } }