From 7cc41bb86e4cc6d93c72e99ff5f06510f70b16d3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 10 Apr 2017 20:46:42 +0200 Subject: [PATCH] add a try catch block around creating nomedia files on Android 4 --- .../com/simplemobiletools/gallery/extensions/activity.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 5fa1540ce..fc9892059 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -170,7 +170,11 @@ fun SimpleActivity.addNoMedia(path: String, callback: () -> Unit) { getFileDocument(path)?.createFile("", NOMEDIA) } } else { - file.createNewFile() + try { + file.createNewFile() + } catch (e: Exception) { + toast(R.string.unknown_error_occurred) + } } scanFile(file) { callback.invoke()