feat: 优化代码

pull/133/head
kunfei 5 years ago
parent de89f651ce
commit f1657637e2
  1. 14
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/SlidePageDelegate.kt

@ -5,6 +5,13 @@ import io.legado.app.ui.book.read.page.PageView
class SlidePageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
override fun setStartPoint(x: Float, y: Float, invalidate: Boolean) {
curPage.x = 0f
prevPage.x = -viewWidth.toFloat()
nextPage.x = viewWidth.toFloat()
super.setStartPoint(x, y, invalidate)
}
override fun onAnimStart() {
val distanceX: Float
when (mDirection) {
@ -37,17 +44,18 @@ class SlidePageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
if (!isMoved) return
if (mDirection == Direction.PREV) {
prevPage.translationX = offsetX - viewWidth
curPage.translationX = offsetX
prevPage.translationX = offsetX - viewWidth + 1f
} else if (mDirection == Direction.NEXT) {
nextPage.translationX = offsetX + viewWidth - 1f
curPage.translationX = offsetX
nextPage.translationX = curPage.x + viewWidth
}
}
override fun onAnimStop() {
curPage.x = 0.toFloat()
curPage.x = 0f
prevPage.x = -viewWidth.toFloat()
nextPage.x = viewWidth.toFloat()
if (!isCancel) {
pageView.fillPage(mDirection)
}

Loading…
Cancel
Save