fix #328, properly handle GIF filtering

This commit is contained in:
tibbi 2017-08-28 14:16:30 +02:00
parent d954dc0d5a
commit 7046fc9ed4

View file

@ -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_BY_SIZE
import com.simplemobiletools.commons.helpers.SORT_DESCENDING import com.simplemobiletools.commons.helpers.SORT_DESCENDING
import com.simplemobiletools.gallery.activities.SettingsActivity import com.simplemobiletools.gallery.activities.SettingsActivity
import com.simplemobiletools.gallery.helpers.Config import com.simplemobiletools.gallery.helpers.*
import com.simplemobiletools.gallery.helpers.IMAGES
import com.simplemobiletools.gallery.helpers.NOMEDIA
import com.simplemobiletools.gallery.helpers.VIDEOS
import com.simplemobiletools.gallery.models.Medium import com.simplemobiletools.gallery.models.Medium
import java.io.File import java.io.File
import java.util.* import java.util.*
@ -97,10 +94,11 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
if (filename.isEmpty()) if (filename.isEmpty())
filename = path.getFilenameFromPath() filename = path.getFilenameFromPath()
val isImage = filename.isImageFast() || filename.isGif() val isImage = filename.isImageFast()
val isVideo = if (isImage) false else filename.isVideoFast() val isVideo = if (isImage) false else filename.isVideoFast()
val isGif = filename.isGif()
if (!isImage && !isVideo) if (!isImage && !isVideo && !isGif)
continue continue
if (isVideo && (isPickImage || filterMedia and VIDEOS == 0)) 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)) if (isImage && (isPickVideo || filterMedia and IMAGES == 0))
continue continue
if (isGif && filterMedia and GIFS == 0)
continue
if (!showHidden && filename.startsWith('.')) if (!showHidden && filename.startsWith('.'))
continue continue
@ -158,8 +159,9 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
} }
val filename = file.name val filename = file.name
val isImage = filename.isImageFast() || filename.isGif() val isImage = filename.isImageFast()
val isVideo = if (isImage) false else filename.isVideoFast() val isVideo = if (isImage) false else filename.isVideoFast()
val isGif = filename.isGif()
if (!isImage && !isVideo) if (!isImage && !isVideo)
continue continue
@ -170,6 +172,9 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP
if (isImage && (isPickVideo || filterMedia and IMAGES == 0)) if (isImage && (isPickVideo || filterMedia and IMAGES == 0))
continue continue
if (isGif && filterMedia and GIFS == 0)
continue
val dateTaken = file.lastModified() val dateTaken = file.lastModified()
val dateModified = file.lastModified() val dateModified = file.lastModified()