From 0f135c845bef33902501a63a01db1faad9d1cd03 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 6 Jun 2017 22:47:16 +0200 Subject: [PATCH] use local variables at fetching media --- .../gallery/extensions/context.kt | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 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 e4e04a2d4..4a47f7ce9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -73,20 +73,13 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP cur.use { cur -> if (cur.moveToFirst()) { - var filename: String - var path: String - var dateTaken: Long - var dateModified: Long - var size: Long - var isImage: Boolean - var isVideo: Boolean val excludedFolders = config.excludedFolders val noMediaFolders = context.getNoMediaFolders() do { try { - path = cur.getStringValue(MediaStore.Images.Media.DATA) - size = cur.getLongValue(MediaStore.Images.Media.SIZE) + val path = cur.getStringValue(MediaStore.Images.Media.DATA) + var size = cur.getLongValue(MediaStore.Images.Media.SIZE) if (size == 0L) { size = File(path).length() } @@ -95,12 +88,12 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP continue } - filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: "" + var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: "" if (filename.isEmpty()) filename = path.getFilenameFromPath() - isImage = filename.isImageFast() || filename.isGif() - isVideo = if (isImage) false else filename.isVideoFast() + val isImage = filename.isImageFast() || filename.isGif() + val isVideo = if (isImage) false else filename.isVideoFast() if (!isImage && !isVideo) continue @@ -134,8 +127,8 @@ private fun parseCursor(context: Context, cur: Cursor, isPickImage: Boolean, isP } if (!isExcluded) { - dateTaken = cur.getLongValue(MediaStore.Images.Media.DATE_TAKEN) - dateModified = cur.getIntValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L + val dateTaken = cur.getLongValue(MediaStore.Images.Media.DATE_TAKEN) + val dateModified = cur.getIntValue(MediaStore.Images.Media.DATE_MODIFIED) * 1000L val medium = Medium(filename, path, isVideo, dateModified, dateTaken, size) curMedia.add(medium)