mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-12-02 09:18:00 +01:00
catch errors thrown at updating a files favorite state
This commit is contained in:
parent
2f15893cda
commit
d9194176ee
1 changed files with 6 additions and 2 deletions
|
@ -801,7 +801,11 @@ fun Context.getFavoriteFromPath(path: String) = Favorite(null, path, path.getFil
|
||||||
|
|
||||||
fun Context.updateFavorite(path: String, isFavorite: Boolean) {
|
fun Context.updateFavorite(path: String, isFavorite: Boolean) {
|
||||||
if (isFavorite) {
|
if (isFavorite) {
|
||||||
|
try {
|
||||||
favoritesDB.insert(getFavoriteFromPath(path))
|
favoritesDB.insert(getFavoriteFromPath(path))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
toast(R.string.unknown_error_occurred)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
favoritesDB.deleteFavoritePath(path)
|
favoritesDB.deleteFavoritePath(path)
|
||||||
}
|
}
|
||||||
|
@ -812,7 +816,7 @@ fun Context.getUpdatedDeletedMedia(): ArrayList<Medium> {
|
||||||
val media = try {
|
val media = try {
|
||||||
mediaDB.getDeletedMedia() as ArrayList<Medium>
|
mediaDB.getDeletedMedia() as ArrayList<Medium>
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
ArrayList<Medium>()
|
ArrayList()
|
||||||
}
|
}
|
||||||
|
|
||||||
media.forEach {
|
media.forEach {
|
||||||
|
|
Loading…
Reference in a new issue