From 08ee4c60efbe6f56bdc4a29b14a9b9d24373e5c6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 11 Jun 2019 16:46:05 +0200 Subject: [PATCH] fix #1449, do not wipe favorite items at fixing date taken values --- .../com/simplemobiletools/gallery/pro/extensions/Context.kt | 6 ++++-- .../simplemobiletools/gallery/pro/interfaces/MediumDao.kt | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) 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)