From 70faf7e7cbde374fc8f0894198e3c0e20315d571 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 26 May 2018 16:55:28 +0200 Subject: [PATCH] always sort folder content by its sorting --- .../simplemobiletools/gallery/activities/MainActivity.kt | 4 ++-- .../gallery/asynctasks/GetMediaAsynctask.kt | 6 +++--- .../com/simplemobiletools/gallery/helpers/MediaFetcher.kt | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 25a73c17d..09098adaf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -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 } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt index d7e17dd43..1f03be404 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt @@ -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 { - 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() 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) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt index 8221d01ef..bb577941c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -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 { + fun getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean, getProperDateTaken: Boolean): ArrayList { 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 }