From a0bdc0b46b50c30c1ba5e0afd13a92d7aff533b3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 20 Feb 2018 14:35:35 +0100 Subject: [PATCH] properly show OTG subfolder thumbnails --- .../gallery/activities/MediaActivity.kt | 5 +-- .../gallery/helpers/MediaFetcher.kt | 34 +++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index dd4d9703d..081d0df72 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -425,10 +425,11 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun hideFolder() { addNoMedia(mPath) { runOnUiThread { - if (!config.shouldShowHidden) + if (!config.shouldShowHidden) { finish() - else + } else { invalidateOptionsMenu() + } } } } 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 65347f4e1..838741c1f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/MediaFetcher.kt @@ -75,21 +75,27 @@ class MediaFetcher(val context: Context) { } fun getFilesFrom(curPath: String, isPickImage: Boolean, isPickVideo: Boolean): ArrayList { - val projection = arrayOf(MediaStore.Images.Media._ID, - MediaStore.Images.Media.DISPLAY_NAME, - MediaStore.Images.Media.DATE_TAKEN, - MediaStore.Images.Media.DATE_MODIFIED, - MediaStore.Images.Media.DATA, - MediaStore.Images.Media.SIZE) - val uri = MediaStore.Files.getContentUri("external") - val selection = getSelectionQuery(curPath) - val selectionArgs = getSelectionArgsQuery(curPath) + if (curPath.startsWith(OTG_PATH)) { + val curMedia = ArrayList() + getMediaOnOTG(curPath, curMedia, isPickImage, isPickVideo, context.config.filterMedia) + return curMedia + } else { + val projection = arrayOf(MediaStore.Images.Media._ID, + MediaStore.Images.Media.DISPLAY_NAME, + MediaStore.Images.Media.DATE_TAKEN, + MediaStore.Images.Media.DATE_MODIFIED, + MediaStore.Images.Media.DATA, + MediaStore.Images.Media.SIZE) + val uri = MediaStore.Files.getContentUri("external") + val selection = getSelectionQuery(curPath) + val selectionArgs = getSelectionArgsQuery(curPath) - return try { - val cur = context.contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath)) - parseCursor(context, cur, isPickImage, isPickVideo, curPath) - } catch (e: Exception) { - ArrayList() + return try { + val cur = context.contentResolver.query(uri, projection, selection, selectionArgs, getSortingForFolder(curPath)) + parseCursor(context, cur, isPickImage, isPickVideo, curPath) + } catch (e: Exception) { + ArrayList() + } } }