[feat] Video position remember& New Icon and Theme
This commit is contained in:
12
app/src/main/java/com/acitelight/aether/model/VideoRecord.kt
Normal file
12
app/src/main/java/com/acitelight/aether/model/VideoRecord.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.acitelight.aether.model
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity
|
||||
data class VideoRecord (
|
||||
@PrimaryKey(autoGenerate = false) val id: String = "",
|
||||
@ColumnInfo(name = "name") val klass: String = "",
|
||||
@ColumnInfo(name = "position") val position: Long
|
||||
)
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.acitelight.aether.model
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import androidx.room.Update
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface VideoRecordDao {
|
||||
@Query("SELECT * FROM videorecord")
|
||||
fun getAll(): Flow<List<VideoRecord>>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insert(rec: VideoRecord)
|
||||
|
||||
@Update
|
||||
suspend fun update(rec: VideoRecord)
|
||||
|
||||
@Delete
|
||||
suspend fun delete(rec: VideoRecord)
|
||||
|
||||
@Query("SELECT * FROM videorecord WHERE id = :id")
|
||||
suspend fun getById(id: String): VideoRecord?
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.acitelight.aether.model
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
|
||||
@Database(entities = [VideoRecord::class], version = 1)
|
||||
abstract class VideoRecordDatabase : RoomDatabase() {
|
||||
abstract fun userDao(): VideoRecordDao
|
||||
|
||||
companion object {
|
||||
@Volatile
|
||||
private var INSTANCE: VideoRecordDatabase? = null
|
||||
|
||||
fun getDatabase(context: Context): VideoRecordDatabase {
|
||||
return INSTANCE ?: synchronized(this) {
|
||||
val instance = Room.databaseBuilder(
|
||||
context.applicationContext,
|
||||
VideoRecordDatabase::class.java,
|
||||
"videorecord_database"
|
||||
).build()
|
||||
INSTANCE = instance
|
||||
instance
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user