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 243298224..ac45129b3 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 @@ -781,11 +781,13 @@ fun Context.addPathToDB(path: String) { else -> TYPE_IMAGES } + val mediumDao = galleryDB.MediumDao() + val isFavorite = mediumDao.isFavorite(path) val videoDuration = if (type == TYPE_VIDEOS) path.getVideoDuration() else 0 val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(), - File(path).length(), type, videoDuration, false, 0L) + File(path).length(), type, videoDuration, isFavorite, 0L) try { - galleryDB.MediumDao().insert(medium) + mediumDao.insert(medium) } catch (ignored: Exception) { } }.start() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt index 1ce2bb641..ed96009a0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/MediumDao.kt @@ -21,6 +21,9 @@ interface MediumDao { @Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, video_duration, is_favorite, deleted_ts FROM media WHERE deleted_ts != 0") fun getDeletedMedia(): List + @Query("SELECT is_favorite FROM media WHERE full_path = :path") + fun isFavorite(path: String): Boolean + @Insert(onConflict = REPLACE) fun insert(medium: Medium)