mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
improve file sorting if sorting by original field is equal
This commit is contained in:
parent
8758b3c9fc
commit
b041d45f80
2 changed files with 11 additions and 3 deletions
|
@ -27,7 +27,7 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage
|
|||
val foldersToScan = mediaFetcher.getFoldersToScan().filter { it != RECYCLE_BIN && it != FAVORITES }
|
||||
val media = ArrayList<Medium>()
|
||||
foldersToScan.forEach {
|
||||
val newMedia = mediaFetcher.getFilesFrom(it, isPickImage, isPickVideo, getProperDateTaken, favoritePaths, getVideoDurations)
|
||||
val newMedia = mediaFetcher.getFilesFrom(it, isPickImage, isPickVideo, getProperDateTaken, favoritePaths, getVideoDurations, false)
|
||||
media.addAll(newMedia)
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class MediaFetcher(val context: Context) {
|
|||
var shouldStop = false
|
||||
|
||||
fun getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean, getProperDateTaken: Boolean, favoritePaths: ArrayList<String>,
|
||||
getVideoDurations: Boolean): ArrayList<Medium> {
|
||||
getVideoDurations: Boolean, sortMedia: Boolean = true): ArrayList<Medium> {
|
||||
val filterMedia = context.config.filterMedia
|
||||
if (filterMedia == 0) {
|
||||
return ArrayList()
|
||||
|
@ -36,7 +36,10 @@ class MediaFetcher(val context: Context) {
|
|||
curMedia.addAll(newMedia)
|
||||
}
|
||||
|
||||
sortMedia(curMedia, context.config.getFileSorting(curPath))
|
||||
if (sortMedia) {
|
||||
sortMedia(curMedia, context.config.getFileSorting(curPath))
|
||||
}
|
||||
|
||||
return curMedia
|
||||
}
|
||||
|
||||
|
@ -366,6 +369,11 @@ class MediaFetcher(val context: Context) {
|
|||
else -> o1.taken.compareTo(o2.taken)
|
||||
}
|
||||
|
||||
// do just a quick extra sorting if the original sorting is equal, does not need to be accurate in all cases
|
||||
if (result == 0 && sorting and SORT_BY_NAME == 0 && sorting and SORT_BY_PATH == 0) {
|
||||
result = o1.name.compareTo(o2.name)
|
||||
}
|
||||
|
||||
if (sorting and SORT_DESCENDING != 0) {
|
||||
result *= -1
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue