mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:55:00 +08:00
feat(ReadBook): 添加跳转进度恢复
This commit is contained in:
parent
9af86699a3
commit
a659c03ff9
@ -42,6 +42,30 @@ object ReadBook : CoroutineScope by MainScope() {
|
||||
private val loadingChapters = arrayListOf<Int>()
|
||||
private val readRecord = ReadRecord()
|
||||
var readStartTime: Long = System.currentTimeMillis()
|
||||
/* 跳转历史记录 */
|
||||
var bookProgressHistory: List<BookProgress>? = null
|
||||
/* 跳转进度前进度记录 */
|
||||
var lastBookPress: BookProgress? = null
|
||||
|
||||
//暂时保存跳转前进度
|
||||
fun saveCurrentBookProcess() {
|
||||
lastBookPress = book?.let { BookProgress(it) }
|
||||
}
|
||||
//恢复跳转前进度
|
||||
fun restoreLastBookProcess() {
|
||||
lastBookPress?.let {
|
||||
durChapterPos = it.durChapterPos
|
||||
if (durChapterIndex != it.durChapterIndex) {
|
||||
clearTextChapter()
|
||||
durChapterIndex = it.durChapterIndex
|
||||
}
|
||||
callBack?.upContent()
|
||||
saveRead()
|
||||
loadContent(resetPageOffset = true) {
|
||||
lastBookPress = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun resetData(book: Book) {
|
||||
ReadBook.book = book
|
||||
@ -55,6 +79,7 @@ object ReadBook : CoroutineScope by MainScope() {
|
||||
callBack?.upMenuView()
|
||||
callBack?.upPageAnim()
|
||||
upWebBook(book)
|
||||
lastBookPress = null
|
||||
synchronized(this) {
|
||||
loadingChapters.clear()
|
||||
}
|
||||
|
@ -926,13 +926,6 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到指定章节
|
||||
*/
|
||||
override fun skipToChapter(index: Int) {
|
||||
viewModel.openChapter(index)
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开搜索界面
|
||||
*/
|
||||
@ -1141,11 +1134,20 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
/* 回复到 全文搜索/进度条跳转前的位置 */
|
||||
|
||||
/* 进度条跳转到指定章节 */
|
||||
override fun skipToChapter(index: Int) {
|
||||
viewModel.openChapter(index)
|
||||
}
|
||||
|
||||
/* 全文搜索跳转 */
|
||||
override fun navigateToSearch(searchResult: SearchResult, index: Int) {
|
||||
viewModel.searchResultIndex = index
|
||||
skipToSearch(searchResult)
|
||||
}
|
||||
|
||||
/* 全文搜索跳转 */
|
||||
private fun skipToSearch(searchResult: SearchResult) {
|
||||
val previousResult = binding.searchMenu.previousSearchResult
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user