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