always sort folder content by its sorting

This commit is contained in:
tibbi 2018-05-26 16:55:28 +02:00
parent ad07068475
commit 70faf7e7cb
3 changed files with 7 additions and 7 deletions

View File

@ -595,7 +595,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
val getProperDateTaken = config.directorySorting and SORT_BY_DATE_TAKEN != 0
for (directory in dirs) {
val curMedia = mediaFetcher.getFilesFrom(directory.path, getImagesOnly, getVideosOnly, config.directorySorting, getProperDateTaken)
val curMedia = mediaFetcher.getFilesFrom(directory.path, getImagesOnly, getVideosOnly, getProperDateTaken)
val newDir = if (curMedia.isEmpty()) {
directory
} else {
@ -638,7 +638,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
// check the remaining folders which were not cached at all yet
for (folder in foldersToScan) {
val newMedia = mediaFetcher.getFilesFrom(folder, getImagesOnly, getVideosOnly, config.directorySorting, getProperDateTaken)
val newMedia = mediaFetcher.getFilesFrom(folder, getImagesOnly, getVideosOnly, getProperDateTaken)
if (newMedia.isEmpty()) {
continue
}

View File

@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.asynctasks
import android.content.Context
import android.os.AsyncTask
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN
import com.simplemobiletools.commons.models.FileDirItem.Companion.sorting
import com.simplemobiletools.gallery.extensions.config
import com.simplemobiletools.gallery.helpers.MediaFetcher
import com.simplemobiletools.gallery.models.Medium
@ -14,20 +15,19 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage
private val mediaFetcher = MediaFetcher(context)
override fun doInBackground(vararg params: Void): ArrayList<Medium> {
val sorting = context.config.getFileSorting(mPath)
val getProperDateTaken = sorting and SORT_BY_DATE_TAKEN != 0
return if (showAll) {
val foldersToScan = mediaFetcher.getFoldersToScan()
val media = ArrayList<Medium>()
foldersToScan.forEach {
val newMedia = mediaFetcher.getFilesFrom(it, isPickImage, isPickVideo, sorting, getProperDateTaken)
val newMedia = mediaFetcher.getFilesFrom(it, isPickImage, isPickVideo, getProperDateTaken)
media.addAll(newMedia)
}
MediaFetcher(context).sortMedia(media, context.config.getFileSorting(""))
media
} else {
mediaFetcher.getFilesFrom(mPath, isPickImage, isPickVideo, sorting, getProperDateTaken)
mediaFetcher.getFilesFrom(mPath, isPickImage, isPickVideo, getProperDateTaken)
}
}

View File

@ -16,7 +16,7 @@ import java.io.File
class MediaFetcher(val context: Context) {
var shouldStop = false
fun getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean, sorting: Int, getProperDateTaken: Boolean): ArrayList<Medium> {
fun getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean, getProperDateTaken: Boolean): ArrayList<Medium> {
val filterMedia = context.config.filterMedia
if (filterMedia == 0) {
return ArrayList()
@ -31,7 +31,7 @@ class MediaFetcher(val context: Context) {
curMedia.addAll(newMedia)
}
sortMedia(curMedia, sorting)
sortMedia(curMedia, context.config.getFileSorting(curPath))
return curMedia
}