From d9194176ee6edea71b0461007fa16a26c3e009c1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 29 Aug 2021 23:25:42 +0200 Subject: [PATCH] catch errors thrown at updating a files favorite state --- .../simplemobiletools/gallery/pro/extensions/Context.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 022bb4761..e221ee87f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -801,7 +801,11 @@ fun Context.getFavoriteFromPath(path: String) = Favorite(null, path, path.getFil fun Context.updateFavorite(path: String, isFavorite: Boolean) { if (isFavorite) { - favoritesDB.insert(getFavoriteFromPath(path)) + try { + favoritesDB.insert(getFavoriteFromPath(path)) + } catch (e: Exception) { + toast(R.string.unknown_error_occurred) + } } else { favoritesDB.deleteFavoritePath(path) } @@ -812,7 +816,7 @@ fun Context.getUpdatedDeletedMedia(): ArrayList { val media = try { mediaDB.getDeletedMedia() as ArrayList } catch (ignored: Exception) { - ArrayList() + ArrayList() } media.forEach {