This commit is contained in:
Horis 2024-02-24 12:34:21 +08:00
parent 7a7a332d35
commit 39ee51dbdd
3 changed files with 5 additions and 16 deletions

View File

@ -90,7 +90,9 @@ object ReadBook : CoroutineScope by MainScope() {
readRecord.readTime = appDb.readRecordDao.getReadTime(book.name) ?: 0
chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl)
contentProcessor = ContentProcessor.get(book)
durChapterIndex = min(book.durChapterIndex, chapterSize - 1)
if (chapterSize > 0) {
durChapterIndex = min(book.durChapterIndex, chapterSize - 1)
}
durChapterPos = book.durChapterPos
isLocalBook = book.isLocal
clearTextChapter()
@ -533,20 +535,17 @@ object ReadBook : CoroutineScope by MainScope() {
0 -> {
curTextChapter?.cancelLayout()
curTextChapter = textChapter
if (resetPageOffset) {
callBack?.resetPageOffset()
}
callBack?.upMenuView()
textChapter.setProgressListener(object : LayoutProgressListener {
var available = false
override fun onLayoutPageCompleted(index: Int, page: TextPage) {
if (!available && page.containPos(durChapterPos)) {
curPageChanged()
callBack?.contentLoadFinish()
if (upContent) {
callBack?.upContent(offset, resetPageOffset)
}
curPageChanged()
callBack?.contentLoadFinish()
available = true
}
if (upContent && isScroll) {
@ -742,8 +741,6 @@ object ReadBook : CoroutineScope by MainScope() {
fun upPageAnim()
fun notifyBookChanged()
fun resetPageOffset()
}
}

View File

@ -1375,10 +1375,6 @@ class ReadBookActivity : BaseReadBookActivity(),
binding.readView.onLayoutPageCompleted(index, page)
}
override fun resetPageOffset() {
binding.readView.resetPageOffset()
}
/* 全文搜索跳转 */
private fun skipToSearch(searchResult: SearchResult) {
val previousResult = binding.searchMenu.previousSearchResult

View File

@ -669,10 +669,6 @@ class ReadView(context: Context, attrs: AttributeSet) :
upProgressThrottle.invoke()
}
fun resetPageOffset() {
curPage.resetPageOffset()
}
override val currentChapter: TextChapter?
get() {
return if (callBack.isInitFinish) ReadBook.textChapter(0) else null