mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-18 22:37:59 +01:00
delete favorites at deleting media
This commit is contained in:
parent
3ca8e685b8
commit
e578036a22
2 changed files with 6 additions and 4 deletions
|
@ -674,6 +674,8 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
|
||||||
try {
|
try {
|
||||||
if (mediaToDelete.isNotEmpty()) {
|
if (mediaToDelete.isNotEmpty()) {
|
||||||
mediaDB.deleteMedia(*mediaToDelete.toTypedArray())
|
mediaDB.deleteMedia(*mediaToDelete.toTypedArray())
|
||||||
|
val favorites = mediaToDelete.map { getFavoriteFromPath(it.path) }
|
||||||
|
favoritesDB.deleteFavorites(*favorites.toTypedArray())
|
||||||
}
|
}
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package com.simplemobiletools.gallery.pro.interfaces
|
package com.simplemobiletools.gallery.pro.interfaces
|
||||||
|
|
||||||
import androidx.room.Dao
|
import androidx.room.*
|
||||||
import androidx.room.Insert
|
|
||||||
import androidx.room.OnConflictStrategy
|
|
||||||
import androidx.room.Query
|
|
||||||
import com.simplemobiletools.gallery.pro.models.Favorite
|
import com.simplemobiletools.gallery.pro.models.Favorite
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
|
@ -23,6 +20,9 @@ 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
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
fun deleteFavorites(vararg favorite: Favorite)
|
||||||
|
|
||||||
@Query("DELETE FROM favorites WHERE full_path = :path COLLATE NOCASE")
|
@Query("DELETE FROM favorites WHERE full_path = :path COLLATE NOCASE")
|
||||||
fun deleteFavoritePath(path: String)
|
fun deleteFavoritePath(path: String)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue