pull/293/head
gedoor 4 years ago
parent 7903479319
commit 274ddede33
  1. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt
  2. 8
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt
  3. 2
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/NoAnimPageDelegate.kt
  4. 22
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt
  5. 10
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt
  6. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt
  7. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/SlidePageDelegate.kt

@ -57,7 +57,7 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
}
}
override fun onAnimStart() {
override fun onAnimStart(animationSpeed: Int) {
val distanceX: Float
when (mDirection) {
Direction.NEXT -> distanceX =
@ -77,7 +77,7 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
viewWidth - (touchX - startX)
}
}
startScroll(touchX.toInt(), 0, distanceX.toInt(), 0)
startScroll(touchX.toInt(), 0, distanceX.toInt(), 0, animationSpeed)
}
}

@ -103,20 +103,20 @@ abstract class HorizontalPageDelegate(pageView: PageView) : PageDelegate(pageVie
}
}
override fun nextPageByAnim() {
override fun nextPageByAnim(animationSpeed: Int) {
abort()
if (!hasNext()) return
setDirection(Direction.NEXT)
setTouchPoint(viewWidth.toFloat(), 0f)
onAnimStart()
onAnimStart(animationSpeed)
}
override fun prevPageByAnim() {
override fun prevPageByAnim(animationSpeed: Int) {
abort()
if (!hasPrev()) return
setDirection(Direction.PREV)
setTouchPoint(0f, 0f)
onAnimStart()
onAnimStart(animationSpeed)
}
override fun onDestroy() {

@ -5,7 +5,7 @@ import io.legado.app.ui.book.read.page.PageView
class NoAnimPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
override fun onAnimStart() {
override fun onAnimStart(animationSpeed: Int) {
if (!isCancel) {
pageView.fillPage(mDirection)
}

@ -24,7 +24,7 @@ abstract class PageDelegate(protected val pageView: PageView) :
pageView.width * 0.66f, pageView.height * 0.66f
)
protected val context: Context = pageView.context
private val animationSpeed = 300
private val defaultAnimationSpeed = 300
//起始点
protected var startX: Float = 0f
@ -115,7 +115,7 @@ abstract class PageDelegate(protected val pageView: PageView) :
pageView.invalidate()
}
protected fun startScroll(startX: Int, startY: Int, dx: Int, dy: Int) {
protected fun startScroll(startX: Int, startY: Int, dx: Int, dy: Int, animationSpeed: Int) {
val duration = if (dx != 0) {
(animationSpeed * abs(dx)) / viewWidth
} else {
@ -163,7 +163,7 @@ abstract class PageDelegate(protected val pageView: PageView) :
return false
}
open fun onAnimStart() {}//scroller start
open fun onAnimStart(animationSpeed: Int) {}//scroller start
open fun onDraw(canvas: Canvas) {}//绘制
@ -171,15 +171,15 @@ abstract class PageDelegate(protected val pageView: PageView) :
open fun onScroll() {}//移动contentView, slidePage
abstract fun nextPageByAnim()
abstract fun nextPageByAnim(animationSpeed: Int)
abstract fun prevPageByAnim()
abstract fun prevPageByAnim(animationSpeed: Int)
open fun keyTurnPage(direction: Direction) {
if (isRunning) return
when (direction) {
Direction.NEXT -> nextPageByAnim()
Direction.PREV -> prevPageByAnim()
Direction.NEXT -> nextPageByAnim(100)
Direction.PREV -> prevPageByAnim(100)
else -> return
}
}
@ -207,7 +207,7 @@ abstract class PageDelegate(protected val pageView: PageView) :
if (selectedOnDown) {
selectedOnDown = false
}
if (!noNext) onAnimStart()
if (!noNext) onAnimStart(defaultAnimationSpeed)
}
}
}
@ -247,7 +247,7 @@ abstract class PageDelegate(protected val pageView: PageView) :
return true
}
if (isMoved) {
if (!noNext) onAnimStart()
if (!noNext) onAnimStart(defaultAnimationSpeed)
return true
}
val x = e.x
@ -259,9 +259,9 @@ abstract class PageDelegate(protected val pageView: PageView) :
if (x > viewWidth / 2 ||
AppConfig.clickAllNext
) {
nextPageByAnim()
nextPageByAnim(defaultAnimationSpeed)
} else {
prevPageByAnim()
prevPageByAnim(defaultAnimationSpeed)
}
}
return true

@ -12,7 +12,7 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) {
//速度追踪器
private val mVelocity: VelocityTracker = VelocityTracker.obtain()
override fun onAnimStart() {
override fun onAnimStart(animationSpeed: Int) {
//惯性滚动
fling(
0, touchY.toInt(), 0, mVelocity.yVelocity.toInt(),
@ -78,13 +78,13 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) {
mVelocity.recycle()
}
override fun nextPageByAnim() {
override fun nextPageByAnim(animationSpeed: Int) {
abort()
startScroll(0, 0, 0, -ChapterProvider.visibleHeight)
startScroll(0, 0, 0, -ChapterProvider.visibleHeight, animationSpeed)
}
override fun prevPageByAnim() {
override fun prevPageByAnim(animationSpeed: Int) {
abort()
startScroll(0, 0, 0, ChapterProvider.visibleHeight)
startScroll(0, 0, 0, ChapterProvider.visibleHeight, animationSpeed)
}
}

@ -154,7 +154,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi
}
}
override fun onAnimStart() {
override fun onAnimStart(animationSpeed: Int) {
var dx: Float
val dy: Float
// dy 垂直方向滑动的距离,负值会使滚动向上滚动
@ -184,7 +184,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi
(1 - touchY) // 防止mTouchY最终变为0
}
}
startScroll(touchX.toInt(), touchY.toInt(), dx.toInt(), dy.toInt())
startScroll(touchX.toInt(), touchY.toInt(), dx.toInt(), dy.toInt(), animationSpeed)
}
override fun onAnimStop() {

@ -8,7 +8,7 @@ class SlidePageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
private val bitmapMatrix = Matrix()
override fun onAnimStart() {
override fun onAnimStart(animationSpeed: Int) {
val distanceX: Float
when (mDirection) {
Direction.NEXT -> distanceX =
@ -28,7 +28,7 @@ class SlidePageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
viewWidth - (touchX - startX)
}
}
startScroll(touchX.toInt(), 0, distanceX.toInt(), 0)
startScroll(touchX.toInt(), 0, distanceX.toInt(), 0, animationSpeed)
}
override fun onDraw(canvas: Canvas) {

Loading…
Cancel
Save