From 277ded39abe36cd2f070f2e713faa188d8d21969 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 19 May 2017 21:20:14 +0200 Subject: [PATCH] wrap the wallpaper setter in a try-catch block --- .../simplemobiletools/gallery/extensions/activity.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 1f5128ffc..05e13b6ba 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -72,10 +72,14 @@ fun Activity.shareMedia(media: List) { } fun Activity.trySetAsWallpaper(file: File) { - var uri = Uri.fromFile(file) - if (!setAsWallpaper(uri, file)) { - uri = getFileContentUri(file) - setAsWallpaper(uri, file, false) + try { + var uri = Uri.fromFile(file) + if (!setAsWallpaper(uri, file)) { + uri = getFileContentUri(file) + setAsWallpaper(uri, file, false) + } + } catch (e: Exception) { + toast(R.string.unknown_error_occurred) } }