From 352dbe40bf0abd5eb8e0e615db860bae51eb7a4a Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 24 Oct 2021 18:35:31 +0200 Subject: [PATCH] catch all exceptions at toggling favorites --- .../gallery/pro/extensions/Context.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 0ba186d14..9f24504b3 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 @@ -847,14 +847,14 @@ fun Context.getFavoritePaths(): ArrayList { fun Context.getFavoriteFromPath(path: String) = Favorite(null, path, path.getFilenameFromPath(), path.getParentPath()) fun Context.updateFavorite(path: String, isFavorite: Boolean) { - if (isFavorite) { - try { + try { + if (isFavorite) { favoritesDB.insert(getFavoriteFromPath(path)) - } catch (e: Exception) { - toast(R.string.unknown_error_occurred) + } else { + favoritesDB.deleteFavoritePath(path) } - } else { - favoritesDB.deleteFavoritePath(path) + } catch (e: Exception) { + toast(R.string.unknown_error_occurred) } }