improve file sorting if sorting by original field is equal

This commit is contained in:
tibbi 2018-12-24 14:05:31 +01:00
parent 8758b3c9fc
commit b041d45f80
2 changed files with 11 additions and 3 deletions

View file

@ -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 foldersToScan = mediaFetcher.getFoldersToScan().filter { it != RECYCLE_BIN && it != FAVORITES }
val media = ArrayList<Medium>() val media = ArrayList<Medium>()
foldersToScan.forEach { 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) media.addAll(newMedia)
} }

View file

@ -19,7 +19,7 @@ class MediaFetcher(val context: Context) {
var shouldStop = false var shouldStop = false
fun getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean, getProperDateTaken: Boolean, favoritePaths: ArrayList<String>, 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 val filterMedia = context.config.filterMedia
if (filterMedia == 0) { if (filterMedia == 0) {
return ArrayList() return ArrayList()
@ -36,7 +36,10 @@ class MediaFetcher(val context: Context) {
curMedia.addAll(newMedia) curMedia.addAll(newMedia)
} }
sortMedia(curMedia, context.config.getFileSorting(curPath)) if (sortMedia) {
sortMedia(curMedia, context.config.getFileSorting(curPath))
}
return curMedia return curMedia
} }
@ -366,6 +369,11 @@ class MediaFetcher(val context: Context) {
else -> o1.taken.compareTo(o2.taken) 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) { if (sorting and SORT_DESCENDING != 0) {
result *= -1 result *= -1
} }