optimize folder visibility checking
This commit is contained in:
parent
1daa85e629
commit
633a1af644
1 changed files with 13 additions and 7 deletions
|
@ -2,6 +2,7 @@ package com.simplemobiletools.gallery.pro.extensions
|
||||||
|
|
||||||
import android.media.MediaMetadataRetriever
|
import android.media.MediaMetadataRetriever
|
||||||
import com.bumptech.glide.signature.ObjectKey
|
import com.bumptech.glide.signature.ObjectKey
|
||||||
|
import com.simplemobiletools.gallery.pro.helpers.NOMEDIA
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
|
@ -17,14 +18,19 @@ fun String.isThisOrParentIncluded(includedPaths: MutableSet<String>) = includedP
|
||||||
fun String.isThisOrParentExcluded(excludedPaths: MutableSet<String>) = excludedPaths.any { startsWith(it, true) }
|
fun String.isThisOrParentExcluded(excludedPaths: MutableSet<String>) = excludedPaths.any { startsWith(it, true) }
|
||||||
|
|
||||||
fun String.shouldFolderBeVisible(excludedPaths: MutableSet<String>, includedPaths: MutableSet<String>, showHidden: Boolean): Boolean {
|
fun String.shouldFolderBeVisible(excludedPaths: MutableSet<String>, includedPaths: MutableSet<String>, showHidden: Boolean): Boolean {
|
||||||
|
if (isEmpty()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
val file = File(this)
|
val file = File(this)
|
||||||
return if (isEmpty()) {
|
if (!showHidden && file.isHidden) {
|
||||||
false
|
return false
|
||||||
} else if (!showHidden && file.isHidden) {
|
|
||||||
false
|
|
||||||
} else if (includedPaths.contains(this)) {
|
} else if (includedPaths.contains(this)) {
|
||||||
true
|
return true
|
||||||
} else if (!showHidden && file.containsNoMedia()) {
|
}
|
||||||
|
|
||||||
|
val containsNoMedia = if (showHidden) false else File(this, NOMEDIA).exists()
|
||||||
|
return if (!showHidden && containsNoMedia) {
|
||||||
false
|
false
|
||||||
} else if (excludedPaths.contains(this)) {
|
} else if (excludedPaths.contains(this)) {
|
||||||
false
|
false
|
||||||
|
@ -33,7 +39,7 @@ fun String.shouldFolderBeVisible(excludedPaths: MutableSet<String>, includedPath
|
||||||
} else if (isThisOrParentExcluded(excludedPaths)) {
|
} else if (isThisOrParentExcluded(excludedPaths)) {
|
||||||
false
|
false
|
||||||
} else if (!showHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) {
|
} else if (!showHidden && file.isDirectory && file.canonicalFile == file.absoluteFile) {
|
||||||
var containsNoMediaOrDot = file.containsNoMedia() || contains("/.")
|
var containsNoMediaOrDot = containsNoMedia || contains("/.")
|
||||||
if (!containsNoMediaOrDot) {
|
if (!containsNoMediaOrDot) {
|
||||||
containsNoMediaOrDot = file.doesThisOrParentHaveNoMedia()
|
containsNoMediaOrDot = file.doesThisOrParentHaveNoMedia()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue