From 55476790046dea8fcc95725764884953df5335a5 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 7 Oct 2017 16:58:56 +0200 Subject: [PATCH] improve the hack for proper displaying of media on Android 4 --- .../gallery/helpers/MediaFetcher.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt index 2fddf4c94..949419c3b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -62,9 +62,12 @@ class MediaFetcher(val context: Context) { } } - private fun getSelectionQuery(path: String): String { + private fun getSelectionQuery(path: String): String? { val dataQuery = "${MediaStore.Images.Media.DATA} LIKE ?" return if (path.isEmpty()) { + if (context.isAndroidFour()) + return null + var query = "($dataQuery)" if (context.hasExternalSDCard()) { query += " OR ($dataQuery)" @@ -75,13 +78,15 @@ class MediaFetcher(val context: Context) { } } - private fun getSelectionArgsQuery(path: String): Array { + private fun getSelectionArgsQuery(path: String): Array? { return if (path.isEmpty()) { + if (context.isAndroidFour()) + return null + if (context.hasExternalSDCard()) { arrayOf("${context.internalStoragePath}/%", "${context.sdCardPath}/%") } else { - val internalPath = if (context.isAndroidFour()) "" else context.internalStoragePath - arrayOf("$internalPath/%") + arrayOf("${context.internalStoragePath}/%") } } else { arrayOf("$path/%", "$path/%/%")