mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 13:08:00 +01:00
fix subfolder counting at "Group direct subfolders"
This commit is contained in:
parent
5482059235
commit
98a5b7144b
1 changed files with 15 additions and 7 deletions
|
@ -967,19 +967,27 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
val newDirs = dirs.filter { foldersToShow.contains(it.path) } as ArrayList<Directory>
|
val newDirs = dirs.filter { foldersToShow.contains(it.path) } as ArrayList<Directory>
|
||||||
|
|
||||||
// update the directory media counts, add all subfolder media counts to it
|
// update the directory media counts, add all subfolder media counts to it
|
||||||
dirs.forEach {
|
for (dir in dirs) {
|
||||||
val mainDir = it
|
|
||||||
var longestSharedPath = ""
|
var longestSharedPath = ""
|
||||||
newDirs.forEach {
|
for (newDir in newDirs) {
|
||||||
if (it.path != mainDir.path && mainDir.path.startsWith(it.path, true) && it.path.length > longestSharedPath.length) {
|
if (newDir.path == dir.path) {
|
||||||
it.subfoldersCount += 1
|
longestSharedPath = dir.path
|
||||||
longestSharedPath = it.path
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dir.path.startsWith(newDir.path, true) && newDir.path.length > longestSharedPath.length) {
|
||||||
|
longestSharedPath = newDir.path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val parentFolder = newDirs.firstOrNull { it.path == longestSharedPath }
|
||||||
|
parentFolder?.apply {
|
||||||
|
subfoldersCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
val mainFolder = newDirs.firstOrNull { it.path == longestSharedPath }
|
val mainFolder = newDirs.firstOrNull { it.path == longestSharedPath }
|
||||||
if (mainFolder != null) {
|
if (mainFolder != null) {
|
||||||
mainFolder.subfoldersMediaCount += mainDir.mediaCnt
|
mainFolder.subfoldersMediaCount += dir.mediaCnt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue