mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
tweaking folder grouping code, no functionality change
This commit is contained in:
parent
f956714979
commit
7f2c76bf27
1 changed files with 8 additions and 7 deletions
|
@ -188,9 +188,7 @@ fun Context.getDirsToShow(dirs: ArrayList<Directory>, allDirs: ArrayList<Directo
|
||||||
it.subfoldersMediaCount = it.mediaCnt
|
it.subfoldersMediaCount = it.mediaCnt
|
||||||
}
|
}
|
||||||
|
|
||||||
val dirFolders = dirs.map { it.path }.sorted().toMutableSet() as HashSet<String>
|
val parentDirs = getDirectParentSubfolders(dirs, currentPathPrefix)
|
||||||
val foldersToShow = getDirectParentSubfolders(dirFolders, currentPathPrefix)
|
|
||||||
val parentDirs = dirs.filter { foldersToShow.contains(it.path) } as ArrayList<Directory>
|
|
||||||
updateSubfolderCounts(dirs, parentDirs)
|
updateSubfolderCounts(dirs, parentDirs)
|
||||||
|
|
||||||
// show the current folder as an available option too, not just subfolders
|
// show the current folder as an available option too, not just subfolders
|
||||||
|
@ -209,7 +207,8 @@ fun Context.getDirsToShow(dirs: ArrayList<Directory>, allDirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getDirectParentSubfolders(folders: HashSet<String>, currentPathPrefix: String): HashSet<String> {
|
fun Context.getDirectParentSubfolders(dirs: ArrayList<Directory>, currentPathPrefix: String): ArrayList<Directory> {
|
||||||
|
val folders = dirs.map { it.path }.sorted().toMutableSet() as HashSet<String>
|
||||||
val internalPath = internalStoragePath
|
val internalPath = internalStoragePath
|
||||||
val sdPath = sdCardPath
|
val sdPath = sdCardPath
|
||||||
val currentPaths = LinkedHashSet<String>()
|
val currentPaths = LinkedHashSet<String>()
|
||||||
|
@ -257,15 +256,17 @@ fun Context.getDirectParentSubfolders(folders: HashSet<String>, currentPathPrefi
|
||||||
}
|
}
|
||||||
|
|
||||||
if (folders.size == currentPaths.size) {
|
if (folders.size == currentPaths.size) {
|
||||||
return currentPaths
|
return dirs.filter { currentPaths.contains(it.path) } as ArrayList<Directory>
|
||||||
}
|
}
|
||||||
|
|
||||||
folders.clear()
|
folders.clear()
|
||||||
folders.addAll(currentPaths)
|
folders.addAll(currentPaths)
|
||||||
|
|
||||||
|
val dirsToShow = dirs.filter { folders.contains(it.path) } as ArrayList<Directory>
|
||||||
return if (areDirectSubfoldersAvailable) {
|
return if (areDirectSubfoldersAvailable) {
|
||||||
getDirectParentSubfolders(folders, currentPathPrefix)
|
getDirectParentSubfolders(dirsToShow, currentPathPrefix)
|
||||||
} else {
|
} else {
|
||||||
folders
|
dirsToShow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue