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

View file

@ -3,6 +3,7 @@ package com.simplemobiletools.gallery.asynctasks
import android.content.Context import android.content.Context
import android.os.AsyncTask import android.os.AsyncTask
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_TAKEN 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.extensions.config
import com.simplemobiletools.gallery.helpers.MediaFetcher import com.simplemobiletools.gallery.helpers.MediaFetcher
import com.simplemobiletools.gallery.models.Medium 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) private val mediaFetcher = MediaFetcher(context)
override fun doInBackground(vararg params: Void): ArrayList<Medium> { override fun doInBackground(vararg params: Void): ArrayList<Medium> {
val sorting = context.config.getFileSorting(mPath)
val getProperDateTaken = sorting and SORT_BY_DATE_TAKEN != 0 val getProperDateTaken = sorting and SORT_BY_DATE_TAKEN != 0
return if (showAll) { return if (showAll) {
val foldersToScan = mediaFetcher.getFoldersToScan() val foldersToScan = mediaFetcher.getFoldersToScan()
val media = ArrayList<Medium>() val media = ArrayList<Medium>()
foldersToScan.forEach { foldersToScan.forEach {
val newMedia = mediaFetcher.getFilesFrom(it, isPickImage, isPickVideo, sorting, getProperDateTaken) val newMedia = mediaFetcher.getFilesFrom(it, isPickImage, isPickVideo, getProperDateTaken)
media.addAll(newMedia) media.addAll(newMedia)
} }
MediaFetcher(context).sortMedia(media, context.config.getFileSorting("")) MediaFetcher(context).sortMedia(media, context.config.getFileSorting(""))
media media
} else { } 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) { class MediaFetcher(val context: Context) {
var shouldStop = false 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 val filterMedia = context.config.filterMedia
if (filterMedia == 0) { if (filterMedia == 0) {
return ArrayList() return ArrayList()
@ -31,7 +31,7 @@ class MediaFetcher(val context: Context) {
curMedia.addAll(newMedia) curMedia.addAll(newMedia)
} }
sortMedia(curMedia, sorting) sortMedia(curMedia, context.config.getFileSorting(curPath))
return curMedia return curMedia
} }