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

View File

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

View File

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