hide folders starting with a dot if hidden should be shown

This commit is contained in:
tibbi 2017-02-26 12:10:15 +01:00
parent 959b0862f5
commit e243de95d1

View file

@ -73,17 +73,22 @@ fun Context.getParents(): ArrayList<String> {
if (config.showHiddenFolders) { if (config.showHiddenFolders) {
parents.addAll(getNoMediaFolders()) parents.addAll(getNoMediaFolders())
} else { } else {
removeNoMediaFolders(parents) removeHiddenFolders(parents)
} }
return parents return parents
} }
private fun removeNoMediaFolders(paths: MutableList<String>) { private fun removeHiddenFolders(paths: MutableList<String>) {
val ignorePaths = ArrayList<String>() val ignorePaths = ArrayList<String>()
for (path in paths) { for (path in paths) {
val dir = File(path) val dir = File(path)
if (dir.exists() && dir.isDirectory) { if (dir.exists() && dir.isDirectory) {
if (dir.name.startsWith(".")) {
ignorePaths.add((path))
continue
}
val res = dir.list { file, filename -> filename == NOMEDIA } val res = dir.list { file, filename -> filename == NOMEDIA }
if (res?.isNotEmpty() == true) if (res?.isNotEmpty() == true)
ignorePaths.add(path) ignorePaths.add(path)