fix #370, make sure only the proper items are shown in "All media" view

This commit is contained in:
tibbi 2017-09-25 23:26:26 +02:00
parent d8811d66b8
commit 64f8d37544

View file

@ -2,7 +2,9 @@ package com.simplemobiletools.gallery.asynctasks
import android.content.Context import android.content.Context
import android.os.AsyncTask import android.os.AsyncTask
import com.simplemobiletools.gallery.extensions.config
import com.simplemobiletools.gallery.extensions.getFilesFrom import com.simplemobiletools.gallery.extensions.getFilesFrom
import com.simplemobiletools.gallery.extensions.getMediaByDirectories
import com.simplemobiletools.gallery.models.Medium import com.simplemobiletools.gallery.models.Medium
import java.util.* import java.util.*
@ -11,8 +13,19 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickVideo
AsyncTask<Void, Void, ArrayList<Medium>>() { AsyncTask<Void, Void, ArrayList<Medium>>() {
override fun doInBackground(vararg params: Void): ArrayList<Medium> { override fun doInBackground(vararg params: Void): ArrayList<Medium> {
val path = if (showAll) "" else mPath return if (showAll) {
return context.getFilesFrom(path, isPickImage, isPickVideo) val mediaMap = context.getMediaByDirectories(isPickVideo, isPickImage)
val media = ArrayList<Medium>()
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<Medium>) { override fun onPostExecute(media: ArrayList<Medium>) {