feat: 优化代码

pull/106/head
kunfei 5 years ago
parent 0a88f1f6fd
commit d4d76e8722
  1. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/NoAnimPageDelegate.kt
  3. 12
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt
  4. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt
  5. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt
  6. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/SlidePageDelegate.kt

@ -18,7 +18,7 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
shadowDrawableR.gradientType = GradientDrawable.LINEAR_GRADIENT
}
override fun onScrollStart() {
override fun onAnimStart() {
val distanceX: Float
when (mDirection) {
Direction.NEXT -> distanceX =
@ -42,7 +42,7 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
startScroll(touchX.toInt(), 0, distanceX.toInt(), 0)
}
override fun onScrollStop() {
override fun onAnimStop() {
curPage.x = 0.toFloat()
if (!isCancel) {
pageView.fillPage(mDirection)

@ -4,14 +4,14 @@ import android.graphics.Canvas
import io.legado.app.ui.book.read.page.PageView
class NoAnimPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
override fun onScrollStart() {
override fun onAnimStart() {
startScroll(touchX.toInt(), 0, 0, 0)
}
override fun onDraw(canvas: Canvas) {
}
override fun onScrollStop() {
override fun onAnimStop() {
if (!isCancel) {
pageView.fillPage(mDirection)
}

@ -140,7 +140,7 @@ abstract class PageDelegate(protected val pageView: PageView) {
setTouchPoint(scroller.currX.toFloat(), scroller.currY.toFloat())
} else if (isStarted) {
setTouchPoint(scroller.finalX.toFloat(), scroller.finalY.toFloat(), false)
onScrollStop()
onAnimStop()
stopScroll()
}
}
@ -176,14 +176,14 @@ abstract class PageDelegate(protected val pageView: PageView) {
return
}
}
onScrollStart()
onAnimStart()
}
abstract fun onScrollStart()//scroller start
abstract fun onAnimStart()//scroller start
abstract fun onDraw(canvas: Canvas)//绘制
abstract fun onScrollStop()//scroller finish
abstract fun onAnimStop()//scroller finish
open fun onScroll() {//移动contentView, slidePage
}
@ -268,7 +268,7 @@ abstract class PageDelegate(protected val pageView: PageView) {
setBitmap()
}
setTouchPoint(x, y)
onScrollStart()
onAnimStart()
}
return true
}
@ -288,7 +288,7 @@ abstract class PageDelegate(protected val pageView: PageView) {
velocityX: Float,
velocityY: Float
): Boolean {
if (!noNext) onScrollStart()
if (!noNext) onAnimStart()
return true
}
}

@ -10,7 +10,7 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) {
private val bitmapMatrix = Matrix()
override fun onScrollStart() {
override fun onAnimStart() {
if (!atTop && !atBottom) {
stopScroll()
return
@ -61,7 +61,7 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) {
}
}
override fun onScrollStop() {
override fun onAnimStop() {
if (!isCancel) {
pageView.fillPage(mDirection)
}

@ -168,7 +168,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi
}
}
override fun onScrollStart() {
override fun onAnimStart() {
var dx: Float
val dy: Float
// dx 水平方向滑动的距离,负值会使滚动向左滚动
@ -202,7 +202,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi
startScroll(touchX.toInt(), touchY.toInt(), dx.toInt(), dy.toInt())
}
override fun onScrollStop() {
override fun onAnimStop() {
if (!isCancel) {
pageView.fillPage(mDirection)
}

@ -8,7 +8,7 @@ class SlidePageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
private val bitmapMatrix = Matrix()
override fun onScrollStart() {
override fun onAnimStart() {
val distanceX: Float
when (mDirection) {
Direction.NEXT -> distanceX =
@ -56,7 +56,7 @@ class SlidePageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
curPage.translationX = offsetX
}
override fun onScrollStop() {
override fun onAnimStop() {
curPage.x = 0.toFloat()
if (!isCancel) {

Loading…
Cancel
Save