阅读记录添加最后阅读时间
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@ val appDb by lazy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
version = 50,
|
version = 51,
|
||||||
exportSchema = true,
|
exportSchema = true,
|
||||||
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
|
entities = [Book::class, BookGroup::class, BookSource::class, BookChapter::class,
|
||||||
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
|
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
|
||||||
@@ -34,7 +34,8 @@ val appDb by lazy {
|
|||||||
AutoMigration(from = 46, to = 47),
|
AutoMigration(from = 46, to = 47),
|
||||||
AutoMigration(from = 47, to = 48),
|
AutoMigration(from = 47, to = 48),
|
||||||
AutoMigration(from = 48, to = 49),
|
AutoMigration(from = 48, to = 49),
|
||||||
AutoMigration(from = 49, to = 50)
|
AutoMigration(from = 49, to = 50),
|
||||||
|
AutoMigration(from = 50, to = 51)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package io.legado.app.data.entities
|
package io.legado.app.data.entities
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
|
|
||||||
@Entity(tableName = "readRecord", primaryKeys = ["deviceId", "bookName"])
|
@Entity(tableName = "readRecord", primaryKeys = ["deviceId", "bookName"])
|
||||||
data class ReadRecord(
|
data class ReadRecord(
|
||||||
var deviceId: String = "",
|
var deviceId: String = "",
|
||||||
var bookName: String = "",
|
var bookName: String = "",
|
||||||
var readTime: Long = 0L
|
@ColumnInfo(defaultValue = "0")
|
||||||
|
var readTime: Long = 0L,
|
||||||
|
@ColumnInfo(defaultValue = "0")
|
||||||
|
var lastRead: Long = System.currentTimeMillis()
|
||||||
)
|
)
|
||||||
@@ -117,6 +117,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
|||||||
Coroutine.async {
|
Coroutine.async {
|
||||||
readRecord.readTime = readRecord.readTime + System.currentTimeMillis() - readStartTime
|
readRecord.readTime = readRecord.readTime + System.currentTimeMillis() - readStartTime
|
||||||
readStartTime = System.currentTimeMillis()
|
readStartTime = System.currentTimeMillis()
|
||||||
|
readRecord.lastRead = System.currentTimeMillis()
|
||||||
if (AppConfig.enableReadRecord) {
|
if (AppConfig.enableReadRecord) {
|
||||||
appDb.readRecordDao.insert(readRecord)
|
appDb.readRecordDao.insert(readRecord)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user