From 1b587b3d10f8a3699533751fe145658ac4afaec2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 21 Nov 2016 18:23:09 +0100 Subject: [PATCH] allow null mime types --- app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt | 2 +- .../com/simplemobiletools/gallery/activities/MainActivity.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt index ccaca98d1..4d89b4be6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/Utils.kt @@ -62,7 +62,7 @@ class Utils { } } - fun getMimeType(url: String): String { + fun getMimeType(url: String): String? { val extension = MimeTypeMap.getFileExtensionFromUrl(url) return if (extension != null) { MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 7dab55c05..0dd8da69d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -250,7 +250,7 @@ class MainActivity : SimpleActivity(), GetDirectoriesAsynctask.GetDirectoriesLis val path = resultData.data.path val uri = Uri.fromFile(File(path)) if (mIsGetImageContentIntent || mIsGetVideoContentIntent || mIsGetAnyContentIntent) { - val type = Utils.getMimeType(path) + val type = Utils.getMimeType(path) ?: "" setDataAndTypeAndNormalize(uri, type) flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION } else if (mIsPickImageIntent || mIsPickVideoIntent) {