diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt index c9516cb43..7801c40e5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/asynctasks/GetMediaAsynctask.kt @@ -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() 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) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt index aeec7fda0..baf207b96 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt @@ -19,7 +19,7 @@ class MediaFetcher(val context: Context) { var shouldStop = false fun getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean, getProperDateTaken: Boolean, favoritePaths: ArrayList, - getVideoDurations: Boolean): ArrayList { + getVideoDurations: Boolean, sortMedia: Boolean = true): ArrayList { 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 }