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 {
|
||||
if (mediaToDelete.isNotEmpty()) {
|
||||
mediaDB.deleteMedia(*mediaToDelete.toTypedArray())
|
||||
val favorites = mediaToDelete.map { getFavoriteFromPath(it.path) }
|
||||
favoritesDB.deleteFavorites(*favorites.toTypedArray())
|
||||
}
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package com.simplemobiletools.gallery.pro.interfaces
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.*
|
||||
import com.simplemobiletools.gallery.pro.models.Favorite
|
||||
|
||||
@Dao
|
||||
|
@ -23,6 +20,9 @@ interface FavoritesDao {
|
|||
@Query("SELECT id FROM favorites WHERE full_path = :path COLLATE NOCASE")
|
||||
fun isFavorite(path: String): Boolean
|
||||
|
||||
@Delete
|
||||
fun deleteFavorites(vararg favorite: Favorite)
|
||||
|
||||
@Query("DELETE FROM favorites WHERE full_path = :path COLLATE NOCASE")
|
||||
fun deleteFavoritePath(path: String)
|
||||
|
||||
|
|
Loading…
Reference in a new issue