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
|
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
|
supportActionBar?.title = mMedium!!.name
|
||||||
bundle.putSerializable(MEDIUM, mMedium)
|
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.Directory
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
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 class GalleryDatabase : RoomDatabase() {
|
||||||
|
|
||||||
abstract fun DirectoryDao(): DirectoryDao
|
abstract fun DirectoryDao(): DirectoryDao
|
||||||
|
|
|
@ -210,7 +210,7 @@ class MediaFetcher(val context: Context) {
|
||||||
else -> TYPE_RAWS
|
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)
|
media.add(medium)
|
||||||
}
|
}
|
||||||
return media
|
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 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)
|
media.add(medium)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.simplemobiletools.gallery.models.Medium
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface MediumDao {
|
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>
|
fun getMediaFromPath(path: String): List<Medium>
|
||||||
|
|
||||||
@Insert(onConflict = REPLACE)
|
@Insert(onConflict = REPLACE)
|
||||||
|
|
|
@ -25,7 +25,8 @@ data class Medium(
|
||||||
@ColumnInfo(name = "last_modified") val modified: Long,
|
@ColumnInfo(name = "last_modified") val modified: Long,
|
||||||
@ColumnInfo(name = "date_taken") var taken: Long,
|
@ColumnInfo(name = "date_taken") var taken: Long,
|
||||||
@ColumnInfo(name = "size") val size: 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 {
|
companion object {
|
||||||
private const val serialVersionUID = -6553149366975455L
|
private const val serialVersionUID = -6553149366975455L
|
||||||
|
|
|
@ -19,7 +19,7 @@ class RefreshMediaReceiver : BroadcastReceiver() {
|
||||||
|
|
||||||
Thread {
|
Thread {
|
||||||
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(), getFileType(path))
|
File(path).length(), getFileType(path), false)
|
||||||
context.galleryDB.MediumDao().insert(medium)
|
context.galleryDB.MediumDao().insert(medium)
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue