From e15d6d850785403f2abac3356f602dc420e1d72c Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Wed, 7 Jun 2017 16:07:01 +0200 Subject: [PATCH] properly open manually included folders --- .../gallery/extensions/context.kt | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 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 b8f37cf99..9df154732 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -139,35 +139,33 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP } } - if (curPath.isEmpty()) { - config.includedFolders.mapNotNull { File(it).listFiles() }.forEach { - for (file in it) { - val size = file.length() - if (size <= 0L) { - continue - } - - val filename = file.name - val isImage = filename.isImageFast() || filename.isGif() - val isVideo = if (isImage) false else filename.isVideoFast() - - if (!isImage && !isVideo) - continue - - if (isVideo && (isPickImage || showMedia == IMAGES)) - continue - - if (isImage && (isPickVideo || showMedia == VIDEOS)) - continue - - val dateTaken = file.lastModified() - val dateModified = file.lastModified() - - val medium = Medium(filename, file.absolutePath, isVideo, dateModified, dateTaken, size) - val isAlreadyAdded = curMedia.any { it.path == file.absolutePath } - if (!isAlreadyAdded) - curMedia.add(medium) + config.includedFolders.filter { it.isEmpty() || it == curPath }.mapNotNull { File(it).listFiles() }.forEach { + for (file in it) { + val size = file.length() + if (size <= 0L) { + continue } + + val filename = file.name + val isImage = filename.isImageFast() || filename.isGif() + val isVideo = if (isImage) false else filename.isVideoFast() + + if (!isImage && !isVideo) + continue + + if (isVideo && (isPickImage || showMedia == IMAGES)) + continue + + if (isImage && (isPickVideo || showMedia == VIDEOS)) + continue + + val dateTaken = file.lastModified() + val dateModified = file.lastModified() + + val medium = Medium(filename, file.absolutePath, isVideo, dateModified, dateTaken, size) + val isAlreadyAdded = curMedia.any { it.path == file.absolutePath } + if (!isAlreadyAdded) + curMedia.add(medium) } }