speed up cached folder fetching by not checking .nomedia multiple times

This commit is contained in:
tibbi 2021-01-13 21:02:06 +01:00
parent c07427c8c2
commit 7957f28b97

View file

@ -576,7 +576,14 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly:
val hiddenString = resources.getString(R.string.hidden) val hiddenString = resources.getString(R.string.hidden)
filteredDirectories.forEach { 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" "${it.name.removeSuffix(hiddenString).trim()} $hiddenString"
} else { } else {
it.name.removeSuffix(hiddenString).trim() it.name.removeSuffix(hiddenString).trim()