From 7ad804f5f961cb8503dc20cec35686ea09b2fb76 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 26 Feb 2017 12:30:42 +0100 Subject: [PATCH] move directory grouping into a separate function --- .../asynctasks/GetDirectoriesAsynctask.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt index 10d99b9a6..2dd0e0f76 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -55,6 +55,15 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va Medium.sorting = fileSorting media.sort() + val directories = groupDirectories(media) + val dirs = ArrayList(directories.values.filter { File(it.path).exists() }) + Directory.sorting = config.directorySorting + dirs.sort() + + return movePinnedToFront(dirs) + } + + private fun groupDirectories(media: ArrayList): Map { val hidden = context.resources.getString(R.string.hidden) val directories = LinkedHashMap() for ((name, path, isVideo, dateModified, dateTaken, size) in media) { @@ -80,12 +89,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va directories.put(parentDir, directory) } } - - val dirs = ArrayList(directories.values.filter { File(it.path).exists() }) - Directory.sorting = config.directorySorting - dirs.sort() - - return movePinnedToFront(dirs) + return directories } private fun movePinnedToFront(dirs: ArrayList): ArrayList {