[新增] 阅读记录时间线视图现在可以显示一次记录的最后阅读章节
This commit is contained in:
7 files changed
+58
-36
No files matched your search
@@ -43,4 +43,13 @@ interface BookChapterDao {
|
||||
@Query("update chapters set wordCount = :wordCount where bookUrl = :bookUrl and url = :url")
|
||||
fun upWordCount(bookUrl: String, url: String, wordCount: String)
|
||||
|
||||
/**
|
||||
* 根据书籍的唯一标识 bookUrl 和章节索引 index 查找章节标题。
|
||||
*/
|
||||
@Query("""
|
||||
SELECT title FROM chapters
|
||||
WHERE bookUrl = :bookUrl
|
||||
AND `index` = :chapterIndex
|
||||
""")
|
||||
suspend fun getChapterTitleByUrlAndIndex(bookUrl: String, chapterIndex: Int): String?
|
||||
}
|
||||
@@ -9,7 +9,8 @@ import org.koin.dsl.module
|
||||
val readRecordModule = module {
|
||||
single { get<AppDatabase>().readRecordDao }
|
||||
single { get<AppDatabase>().bookDao }
|
||||
single { get<AppDatabase>().bookChapterDao }
|
||||
single { ReadRecordRepository(get()) }
|
||||
|
||||
viewModel { ReadRecordViewModel(get(), get()) }
|
||||
viewModel { ReadRecordViewModel(get(), get(), get()) }
|
||||
}
|
||||
@@ -312,7 +312,7 @@ object ReadBook : CoroutineScope by MainScope(), KoinComponent {
|
||||
bookName = currentBookName,
|
||||
startTime = readStartTime,
|
||||
endTime = readStartTime,
|
||||
words = 0
|
||||
words = durChapterIndex.toLong()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -327,12 +327,9 @@ object ReadBook : CoroutineScope by MainScope(), KoinComponent {
|
||||
return
|
||||
}
|
||||
|
||||
var wordChange = currentLength - lastReadLength
|
||||
if (wordChange < 0) wordChange = 0
|
||||
|
||||
currentActiveSession = currentActiveSession!!.copy(
|
||||
endTime = endTime,
|
||||
words = currentActiveSession!!.words + wordChange
|
||||
words = durChapterIndex.toLong()
|
||||
)
|
||||
|
||||
readStartTime = endTime
|
||||
|
||||