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 pageOffset += offset
if (pageOffset > 0) { if (!pageFactory.hasPrev() && pageOffset > 0) {
if (!pageFactory.hasPrev()) { pageOffset = 0f
pageOffset = 0f } else if (!pageFactory.hasNext() && pageOffset < 0) {
} else { pageOffset = 0f
pageFactory.moveToPrev() } else if (pageOffset > 0) {
textPage = pageFactory.currentPage pageFactory.moveToPrev()
pageOffset -= textPage.height textPage = pageFactory.currentPage
upView?.invoke(textPage) pageOffset -= textPage.height
} upView?.invoke(textPage)
} else if (pageOffset < -textPage.height) { } else if (pageOffset < -textPage.height) {
if (!pageFactory.hasNext()) { pageOffset += textPage.height
pageOffset = -textPage.height.toFloat() pageFactory.moveToNext()
} else { textPage = pageFactory.currentPage
pageOffset += textPage.height upView?.invoke(textPage)
pageFactory.moveToNext()
textPage = pageFactory.currentPage
upView?.invoke(textPage)
}
} }
invalidate() invalidate()
} }

Loading…
Cancel
Save