From 8af103d98c67151dc4d26d65f2c2d25b2c367375 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 22 Apr 2018 10:32:13 +0200 Subject: [PATCH] filter cached media by type too --- .../com/simplemobiletools/gallery/extensions/Context.kt | 8 ++++++++ .../com/simplemobiletools/gallery/helpers/MediaFetcher.kt | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt index 906c0f026..bbc9f8129 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/Context.kt @@ -263,6 +263,14 @@ fun Context.getCachedMedia(path: String, callback: (ArrayList) -> Unit) if (!shouldShowHidden) { filteredMedia = media.filter { !it.name.startsWith('.') } as ArrayList } + + val filterMedia = config.filterMedia + filteredMedia = filteredMedia.filter { + (filterMedia and IMAGES != 0 && it.type == TYPE_IMAGE) || + (filterMedia and VIDEOS != 0 && it.type == TYPE_VIDEO) || + (filterMedia and GIFS != 0 && it.type == TYPE_GIF) + } as ArrayList + callback(filteredMedia) media.filter { !File(it.path).exists() }.forEach { 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 ccb160104..2068d35c0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -167,7 +167,6 @@ class MediaFetcher(val context: Context) { private fun groupDirectories(media: ArrayList): HashMap> { val directories = LinkedHashMap>() - val hasOTG = context.hasOTGConnected() && context.config.OTGBasePath.isNotEmpty() for (medium in media) { if (shouldStop) { break @@ -226,7 +225,6 @@ class MediaFetcher(val context: Context) { else -> TYPE_GIF } - val parentPath = file.absolutePath.removeSuffix("/") val medium = Medium(null, filename, file.absolutePath, folder, dateModified, dateTaken, size, type) curMedia.add(medium) }