mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
apply the custom sorting when appropriate
This commit is contained in:
parent
552c98c270
commit
3450c2e41d
1 changed files with 12 additions and 0 deletions
|
@ -114,6 +114,18 @@ fun Context.getSortedDirectories(source: ArrayList<Directory>): ArrayList<Direct
|
|||
if (sorting and SORT_BY_RANDOM != 0) {
|
||||
dirs.shuffle()
|
||||
return movePinnedDirectoriesToFront(dirs)
|
||||
} else if (sorting and SORT_BY_CUSTOM != 0) {
|
||||
val newDirsOrdered = ArrayList<Directory>()
|
||||
config.customFoldersOrder.split("|||").forEach { path ->
|
||||
val index = dirs.indexOfFirst { it.path == path }
|
||||
if (index != -1) {
|
||||
val dir = dirs.removeAt(index)
|
||||
newDirsOrdered.add(dir)
|
||||
}
|
||||
}
|
||||
|
||||
dirs.mapTo(newDirsOrdered, { it })
|
||||
return newDirsOrdered
|
||||
}
|
||||
|
||||
dirs.sortWith(Comparator { o1, o2 ->
|
||||
|
|
Loading…
Reference in a new issue