From 64f8d3754474aee5ad8c672a72b6d57a658f134d Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 25 Sep 2017 23:26:26 +0200 Subject: [PATCH] fix #370, make sure only the proper items are shown in "All media" view --- .../gallery/asynctasks/GetMediaAsynctask.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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 68595ae46..13002eb86 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetMediaAsynctask.kt @@ -2,7 +2,9 @@ package com.simplemobiletools.gallery.asynctasks import android.content.Context import android.os.AsyncTask +import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.getFilesFrom +import com.simplemobiletools.gallery.extensions.getMediaByDirectories import com.simplemobiletools.gallery.models.Medium import java.util.* @@ -11,8 +13,19 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo AsyncTask>() { override fun doInBackground(vararg params: Void): ArrayList { - val path = if (showAll) "" else mPath - return context.getFilesFrom(path, isPickImage, isPickVideo) + return if (showAll) { + val mediaMap = context.getMediaByDirectories(isPickVideo, isPickImage) + val media = ArrayList() + for ((path, curMedia) in mediaMap) { + media.addAll(curMedia) + } + + Medium.sorting = context.config.getFileSorting("") + media.sort() + media + } else { + context.getFilesFrom(mPath, isPickImage, isPickVideo) + } } override fun onPostExecute(media: ArrayList) {