From 4ca455c761a7a5277b3186077387df44733c4f6b Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 27 Feb 2017 23:29:19 +0100 Subject: [PATCH] group the media files at querying the content resolver --- .../com/simplemobiletools/gallery/extensions/context.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 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 1877868b1..0012b1a06 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/context.kt @@ -50,12 +50,13 @@ fun Context.launchSettings() { fun Context.getParents(): ArrayList { val uri = MediaStore.Files.getContentUri("external") - val columns = arrayOf(MediaStore.Images.Media.DATA) + val columns = arrayOf(MediaStore.Files.FileColumns.PARENT, MediaStore.Images.Media.DATA) + val where = "${MediaStore.Images.Media.DATA} IS NOT NULL) GROUP BY (${MediaStore.Files.FileColumns.PARENT} " val parentsSet = HashSet() var cursor: Cursor? = null try { - cursor = contentResolver.query(uri, columns, null, null, null) + cursor = contentResolver.query(uri, columns, where, null, null) if (cursor?.moveToFirst() == true) { do { val curPath = cursor.getStringValue(MediaStore.Images.Media.DATA) ?: continue