Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Nov 3, 2023
1 parent c2a1303 commit ae7ef9b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,9 @@ class ReadBookActivity : BaseReadBookActivity(),
if (menuLayoutIsVisible) {
return
}
if (binding.readView.run { isScroll && pageDelegate?.isRunning == true }) {
return
}
val readTime = ReadBookConfig.autoReadSpeed * 1000.0
val height = binding.readView.height
val scrollOffset = (height / readTime * frameTime).toInt().coerceAtLeast(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
val offset = (ChapterProvider.visibleHeight - textPage.height).toInt()
pageOffset = min(0, offset)
} else if (pageOffset > 0) {
pageFactory.moveToPrev(false)
pageFactory.moveToPrev(true)
textPage = pageFactory.curPage
pageOffset -= textPage.height.toInt()
upView?.invoke(textPage)
contentDescription = textPage.text
} else if (pageOffset < -textPage.height) {
pageOffset += textPage.height.toInt()
pageFactory.moveToNext(false)
pageFactory.moveToNext(true)
textPage = pageFactory.curPage
upView?.invoke(textPage)
contentDescription = textPage.text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,12 +526,11 @@ class ReadView(context: Context, attrs: AttributeSet) :
if (isScroll && !callBack.isAutoPage) {
curPage.setContent(pageFactory.curPage, resetPageOffset)
} else {
curPage.resetPageOffset()
when (relativePosition) {
-1 -> prevPage.setContent(pageFactory.prevPage)
1 -> nextPage.setContent(pageFactory.nextPage)
else -> {
curPage.setContent(pageFactory.curPage)
curPage.setContent(pageFactory.curPage, resetPageOffset)
nextPage.setContent(pageFactory.nextPage)
prevPage.setContent(pageFactory.prevPage)
}
Expand Down

0 comments on commit ae7ef9b

Please sign in to comment.