From 2c73864d74fc15efa7f8640e8f798b6325f41587 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 26 May 2017 09:29:02 +0200 Subject: [PATCH] catch exceptions at creating nomedia files on sd cards --- .../com/simplemobiletools/gallery/extensions/activity.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt index ead1336a2..b1663b850 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -218,7 +218,11 @@ fun SimpleActivity.addNoMedia(path: String, callback: () -> Unit) { if (needsStupidWritePermissions(path)) { handleSAFDialog(file) { - getFileDocument(path)?.createFile("", NOMEDIA) + try { + getFileDocument(path)?.createFile("", NOMEDIA) + } catch (e: Exception) { + toast(R.string.unknown_error_occurred) + } } } else { try { @@ -228,7 +232,7 @@ fun SimpleActivity.addNoMedia(path: String, callback: () -> Unit) { } } scanFile(file) { - callback.invoke() + callback() } }