avoid reseting favorite items in one more case

This commit is contained in:
tibbi 2019-06-11 16:56:42 +02:00
parent 08ee4c60ef
commit 6f6449c2b7

View file

@ -325,7 +325,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
if (intent.action == "com.android.camera.action.REVIEW") { if (intent.action == "com.android.camera.action.REVIEW") {
Thread { Thread {
if (galleryDB.MediumDao().getMediaFromPath(mPath).isEmpty()) { val mediumDao = galleryDB.MediumDao()
if (mediumDao.getMediaFromPath(mPath).isEmpty()) {
val type = when { val type = when {
mPath.isVideoFast() -> TYPE_VIDEOS mPath.isVideoFast() -> TYPE_VIDEOS
mPath.isGif() -> TYPE_GIFS mPath.isGif() -> TYPE_GIFS
@ -334,9 +335,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
else -> TYPE_IMAGES else -> TYPE_IMAGES
} }
val isFavorite = mediumDao.isFavorite(mPath)
val duration = if (type == TYPE_VIDEOS) mPath.getVideoDuration() else 0 val duration = if (type == TYPE_VIDEOS) mPath.getVideoDuration() else 0
val medium = Medium(null, mPath.getFilenameFromPath(), mPath, mPath.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(), File(mPath).length(), type, duration, false, 0) val ts = System.currentTimeMillis()
galleryDB.MediumDao().insert(medium) val medium = Medium(null, mPath.getFilenameFromPath(), mPath, mPath.getParentPath(), ts, ts, File(mPath).length(), type, duration, isFavorite, 0)
mediumDao.insert(medium)
} }
}.start() }.start()
} }