From 7957f28b97cac8e999c6d6a33de5424f7a66db81 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 13 Jan 2021 21:02:06 +0100 Subject: [PATCH] speed up cached folder fetching by not checking .nomedia multiple times --- .../simplemobiletools/gallery/pro/extensions/Context.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 03b5ad783..3ecb7fe75 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 @@ -576,7 +576,14 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly: val hiddenString = resources.getString(R.string.hidden) filteredDirectories.forEach { - it.name = if (it.path.doesThisOrParentHaveNoMedia(noMediaFolders) && !it.path.isThisOrParentIncluded(includedPaths)) { + 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()