feat: 优化代码

pull/123/head
kunfei 5 years ago
parent 4d621485d3
commit 66b88fab28
  1. 30
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt

@ -163,24 +163,20 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
}
pageOffset += offset
if (pageOffset > 0) {
if (!pageFactory.hasPrev()) {
pageOffset = 0f
} else {
pageFactory.moveToPrev()
textPage = pageFactory.currentPage
pageOffset -= textPage.height
upView?.invoke(textPage)
}
if (!pageFactory.hasPrev() && pageOffset > 0) {
pageOffset = 0f
} else if (!pageFactory.hasNext() && pageOffset < 0) {
pageOffset = 0f
} else if (pageOffset > 0) {
pageFactory.moveToPrev()
textPage = pageFactory.currentPage
pageOffset -= textPage.height
upView?.invoke(textPage)
} else if (pageOffset < -textPage.height) {
if (!pageFactory.hasNext()) {
pageOffset = -textPage.height.toFloat()
} else {
pageOffset += textPage.height
pageFactory.moveToNext()
textPage = pageFactory.currentPage
upView?.invoke(textPage)
}
pageOffset += textPage.height
pageFactory.moveToNext()
textPage = pageFactory.currentPage
upView?.invoke(textPage)
}
invalidate()
}

Loading…
Cancel
Save