feat: 优化代码

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

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

Loading…
Cancel
Save