feat: 优化代码

pull/379/head
kunfei 5 years ago
parent 5944c994cb
commit 53168c02b0
  1. 4
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  2. 28
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt

@ -120,7 +120,7 @@ class PageView(context: Context, attrs: AttributeSet) :
if (noAnim) {
fillPage(PageDelegate.Direction.PREV)
} else {
pageDelegate?.start(PageDelegate.Direction.PREV)
pageDelegate?.prevPageByAnim()
}
}
@ -128,7 +128,7 @@ class PageView(context: Context, attrs: AttributeSet) :
if (noAnim) {
fillPage(PageDelegate.Direction.NEXT)
} else {
pageDelegate?.start(PageDelegate.Direction.NEXT)
pageDelegate?.nextPageByAnim()
}
}

@ -158,34 +158,6 @@ abstract class PageDelegate(protected val pageView: PageView) :
}
}
fun start(direction: Direction) {
if (isStarted) return
if (direction === Direction.NEXT) {
val x = viewWidth.toFloat()
val y = viewHeight.toFloat()
//初始化动画
setStartPoint(x, y, false)
//设置点击点
setTouchPoint(x, y, false)
//设置方向
if (!hasNext()) {
return
}
} else {
val x = 0.toFloat()
val y = viewHeight.toFloat()
//初始化动画
setStartPoint(x, y, false)
//设置点击点
setTouchPoint(x, y, false)
//设置方向方向
if (!hasPrev()) {
return
}
}
onAnimStart()
}
open fun onAnimStart() {}//scroller start
open fun onDraw(canvas: Canvas) {}//绘制

Loading…
Cancel
Save