moving the isFavorite function at FavoritesDAO
This commit is contained in:
parent
4e2380f13a
commit
56d721b68a
4 changed files with 5 additions and 6 deletions
|
@ -375,7 +375,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
else -> TYPE_IMAGES
|
else -> TYPE_IMAGES
|
||||||
}
|
}
|
||||||
|
|
||||||
val isFavorite = mediumDao.isFavorite(mPath)
|
val isFavorite = galleryDB.FavoritesDAO().isFavorite(mPath)
|
||||||
val duration = if (type == TYPE_VIDEOS) mPath.getVideoDuration() else 0
|
val duration = if (type == TYPE_VIDEOS) mPath.getVideoDuration() else 0
|
||||||
val ts = System.currentTimeMillis()
|
val ts = System.currentTimeMillis()
|
||||||
val medium = Medium(null, mPath.getFilenameFromPath(), mPath, mPath.getParentPath(), ts, ts, File(mPath).length(), type, duration, isFavorite, 0)
|
val medium = Medium(null, mPath.getFilenameFromPath(), mPath, mPath.getParentPath(), ts, ts, File(mPath).length(), type, duration, isFavorite, 0)
|
||||||
|
|
|
@ -827,7 +827,7 @@ fun Context.addPathToDB(path: String) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val mediumDao = galleryDB.MediumDao()
|
val mediumDao = galleryDB.MediumDao()
|
||||||
val isFavorite = mediumDao.isFavorite(path)
|
val isFavorite = galleryDB.FavoritesDAO().isFavorite(path)
|
||||||
val videoDuration = if (type == TYPE_VIDEOS) path.getVideoDuration() else 0
|
val videoDuration = if (type == TYPE_VIDEOS) path.getVideoDuration() else 0
|
||||||
val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(),
|
val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(),
|
||||||
File(path).length(), type, videoDuration, isFavorite, 0L)
|
File(path).length(), type, videoDuration, isFavorite, 0L)
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.simplemobiletools.gallery.pro.interfaces
|
package com.simplemobiletools.gallery.pro.interfaces
|
||||||
|
|
||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Query
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface FavoritesDAO {
|
interface FavoritesDAO {
|
||||||
|
@Query("SELECT id FROM favorites WHERE full_path = :path COLLATE NOCASE")
|
||||||
|
fun isFavorite(path: String): Boolean
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@ 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")
|
@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<Medium>
|
fun getDeletedMedia(): List<Medium>
|
||||||
|
|
||||||
@Query("SELECT is_favorite FROM media WHERE full_path = :path COLLATE NOCASE")
|
|
||||||
fun isFavorite(path: String): Boolean
|
|
||||||
|
|
||||||
@Insert(onConflict = REPLACE)
|
@Insert(onConflict = REPLACE)
|
||||||
fun insert(medium: Medium)
|
fun insert(medium: Medium)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue