move directory grouping into a separate function
This commit is contained in:
parent
ad8cd557ce
commit
7ad804f5f9
1 changed files with 10 additions and 6 deletions
|
@ -55,6 +55,15 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
||||||
Medium.sorting = fileSorting
|
Medium.sorting = fileSorting
|
||||||
media.sort()
|
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<Medium>): Map<String, Directory> {
|
||||||
val hidden = context.resources.getString(R.string.hidden)
|
val hidden = context.resources.getString(R.string.hidden)
|
||||||
val directories = LinkedHashMap<String, Directory>()
|
val directories = LinkedHashMap<String, Directory>()
|
||||||
for ((name, path, isVideo, dateModified, dateTaken, size) in media) {
|
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)
|
directories.put(parentDir, directory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return directories
|
||||||
val dirs = ArrayList(directories.values.filter { File(it.path).exists() })
|
|
||||||
Directory.sorting = config.directorySorting
|
|
||||||
dirs.sort()
|
|
||||||
|
|
||||||
return movePinnedToFront(dirs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun movePinnedToFront(dirs: ArrayList<Directory>): ArrayList<Directory> {
|
private fun movePinnedToFront(dirs: ArrayList<Directory>): ArrayList<Directory> {
|
||||||
|
|
Loading…
Reference in a new issue