From 3450c2e41dac44a519d780d7ff2aeb8f50ec201e Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 13 May 2021 19:29:55 +0200 Subject: [PATCH] apply the custom sorting when appropriate --- .../gallery/pro/extensions/Context.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index cd120112d..ad27c0495 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -114,6 +114,18 @@ fun Context.getSortedDirectories(source: ArrayList): ArrayList() + 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 ->