From 624c0e2d083e780fade5ab541d277589eab03841 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 11 Sep 2017 21:34:15 +0200 Subject: [PATCH] check the filesize only after checking the file type --- .../gallery/extensions/context.kt | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 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 d0d6dcd00..3d0d115b6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -81,14 +81,6 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP do { try { val path = cur.getStringValue(MediaStore.Images.Media.DATA) - var size = cur.getLongValue(MediaStore.Images.Media.SIZE) - if (size == 0L) { - size = File(path).length() - } - - if (size <= 0L) { - continue - } var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: "" if (filename.isEmpty()) @@ -113,6 +105,15 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP if (!showHidden && filename.startsWith('.')) continue + var size = cur.getLongValue(MediaStore.Images.Media.SIZE) + val file = File(path) + if (size == 0L) { + size = file.length() + } + + if (size <= 0L) + continue + var isExcluded = false excludedFolders.forEach { if (path.startsWith(it)) { @@ -168,11 +169,6 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP private fun getMediaInFolder(folder: String, curMedia: ArrayList, isPickImage: Boolean, isPickVideo: Boolean, filterMedia: Int) { val files = File(folder).listFiles() ?: return for (file in files) { - val size = file.length() - if (size <= 0L) { - continue - } - val filename = file.name val isImage = filename.isImageFast() val isVideo = if (isImage) false else filename.isVideoFast() @@ -190,6 +186,10 @@ private fun getMediaInFolder(folder: String, curMedia: ArrayList, isPick if (isGif && filterMedia and GIFS == 0) continue + val size = file.length() + if (size <= 0L) + continue + val dateTaken = file.lastModified() val dateModified = file.lastModified()