adding a new Medium field isFavorite
This commit is contained in:
parent
158d7322ee
commit
703aa7bbd1
6 changed files with 8 additions and 7 deletions
|
@ -95,7 +95,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
|||
else -> TYPE_RAWS
|
||||
}
|
||||
|
||||
mMedium = Medium(null, getFilenameFromUri(mUri!!), mUri.toString(), mUri!!.path.getParentPath(), 0, 0, file.length(), type)
|
||||
mMedium = Medium(null, getFilenameFromUri(mUri!!), mUri.toString(), mUri!!.path.getParentPath(), 0, 0, file.length(), type, false)
|
||||
supportActionBar?.title = mMedium!!.name
|
||||
bundle.putSerializable(MEDIUM, mMedium)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.simplemobiletools.gallery.interfaces.MediumDao
|
|||
import com.simplemobiletools.gallery.models.Directory
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
|
||||
@Database(entities = [(Directory::class), (Medium::class)], version = 2)
|
||||
@Database(entities = [(Directory::class), (Medium::class)], version = 3)
|
||||
abstract class GalleryDatabase : RoomDatabase() {
|
||||
|
||||
abstract fun DirectoryDao(): DirectoryDao
|
||||
|
|
|
@ -210,7 +210,7 @@ class MediaFetcher(val context: Context) {
|
|||
else -> TYPE_RAWS
|
||||
}
|
||||
|
||||
val medium = Medium(null, filename, file.absolutePath, folder, lastModified, dateTaken, size, type)
|
||||
val medium = Medium(null, filename, file.absolutePath, folder, lastModified, dateTaken, size, type, false)
|
||||
media.add(medium)
|
||||
}
|
||||
return media
|
||||
|
@ -266,7 +266,7 @@ class MediaFetcher(val context: Context) {
|
|||
}
|
||||
|
||||
val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGTreeUri}/document/${context.config.OTGPartition}%3A", OTG_PATH))
|
||||
val medium = Medium(null, filename, path, folder, dateModified, dateTaken, size, type)
|
||||
val medium = Medium(null, filename, path, folder, dateModified, dateTaken, size, type, false)
|
||||
media.add(medium)
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.simplemobiletools.gallery.models.Medium
|
|||
|
||||
@Dao
|
||||
interface MediumDao {
|
||||
@Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type FROM media WHERE parent_path = :path")
|
||||
@Query("SELECT filename, full_path, parent_path, last_modified, date_taken, size, type, is_favorite FROM media WHERE parent_path = :path")
|
||||
fun getMediaFromPath(path: String): List<Medium>
|
||||
|
||||
@Insert(onConflict = REPLACE)
|
||||
|
|
|
@ -25,7 +25,8 @@ data class Medium(
|
|||
@ColumnInfo(name = "last_modified") val modified: Long,
|
||||
@ColumnInfo(name = "date_taken") var taken: Long,
|
||||
@ColumnInfo(name = "size") val size: Long,
|
||||
@ColumnInfo(name = "type") val type: Int) : Serializable {
|
||||
@ColumnInfo(name = "type") val type: Int,
|
||||
@ColumnInfo(name = "is_favorite") val isFavorite: Boolean) : Serializable {
|
||||
|
||||
companion object {
|
||||
private const val serialVersionUID = -6553149366975455L
|
||||
|
|
|
@ -19,7 +19,7 @@ class RefreshMediaReceiver : BroadcastReceiver() {
|
|||
|
||||
Thread {
|
||||
val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(),
|
||||
File(path).length(), getFileType(path))
|
||||
File(path).length(), getFileType(path), false)
|
||||
context.galleryDB.MediumDao().insert(medium)
|
||||
}.start()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue