at deleting a file path from db, delete it from favorites too
This commit is contained in:
parent
56d721b68a
commit
b867d2a2eb
2 changed files with 9 additions and 1 deletions
|
@ -736,8 +736,13 @@ fun Context.getUpdatedDeletedMedia(mediumDao: MediumDao): ArrayList<Medium> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.deleteDBPath(mediumDao: MediumDao, path: String) {
|
fun Context.deleteDBPath(mediumDao: MediumDao, path: String) {
|
||||||
|
deleteMediumWithPath(mediumDao, path.replaceFirst(recycleBinPath, RECYCLE_BIN))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Context.deleteMediumWithPath(mediumDao: MediumDao, path: String) {
|
||||||
try {
|
try {
|
||||||
mediumDao.deleteMediumPath(path.replaceFirst(recycleBinPath, RECYCLE_BIN))
|
mediumDao.deleteMediumPath(path)
|
||||||
|
galleryDB.FavoritesDAO().deleteFavoritePath(path)
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,4 +7,7 @@ import androidx.room.Query
|
||||||
interface FavoritesDAO {
|
interface FavoritesDAO {
|
||||||
@Query("SELECT id FROM favorites WHERE full_path = :path COLLATE NOCASE")
|
@Query("SELECT id FROM favorites WHERE full_path = :path COLLATE NOCASE")
|
||||||
fun isFavorite(path: String): Boolean
|
fun isFavorite(path: String): Boolean
|
||||||
|
|
||||||
|
@Query("DELETE FROM favorites WHERE full_path = :path COLLATE NOCASE")
|
||||||
|
fun deleteFavoritePath(path: String)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue