From 7046fc9ed4a40d2214374eb84fe9863b491bb015 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 28 Aug 2017 14:16:30 +0200 Subject: [PATCH] fix #328, properly handle GIF filtering --- .../gallery/extensions/context.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 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 5dc6c7dc3..b95cabbff 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -13,10 +13,7 @@ import com.simplemobiletools.commons.helpers.SORT_BY_NAME import com.simplemobiletools.commons.helpers.SORT_BY_SIZE import com.simplemobiletools.commons.helpers.SORT_DESCENDING import com.simplemobiletools.gallery.activities.SettingsActivity -import com.simplemobiletools.gallery.helpers.Config -import com.simplemobiletools.gallery.helpers.IMAGES -import com.simplemobiletools.gallery.helpers.NOMEDIA -import com.simplemobiletools.gallery.helpers.VIDEOS +import com.simplemobiletools.gallery.helpers.* import com.simplemobiletools.gallery.models.Medium import java.io.File import java.util.* @@ -97,10 +94,11 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP if (filename.isEmpty()) filename = path.getFilenameFromPath() - val isImage = filename.isImageFast() || filename.isGif() + val isImage = filename.isImageFast() val isVideo = if (isImage) false else filename.isVideoFast() + val isGif = filename.isGif() - if (!isImage && !isVideo) + if (!isImage && !isVideo && !isGif) continue if (isVideo && (isPickImage || filterMedia and VIDEOS == 0)) @@ -109,6 +107,9 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP if (isImage && (isPickVideo || filterMedia and IMAGES == 0)) continue + if (isGif && filterMedia and GIFS == 0) + continue + if (!showHidden && filename.startsWith('.')) continue @@ -158,8 +159,9 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP } val filename = file.name - val isImage = filename.isImageFast() || filename.isGif() + val isImage = filename.isImageFast() val isVideo = if (isImage) false else filename.isVideoFast() + val isGif = filename.isGif() if (!isImage && !isVideo) continue @@ -170,6 +172,9 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP if (isImage && (isPickVideo || filterMedia and IMAGES == 0)) continue + if (isGif && filterMedia and GIFS == 0) + continue + val dateTaken = file.lastModified() val dateModified = file.lastModified()