|
|
@ -50,6 +50,7 @@ abstract class PageDelegate(protected val pageView: PageView) { |
|
|
|
var isCancel = false |
|
|
|
var isCancel = false |
|
|
|
var isRunning = false |
|
|
|
var isRunning = false |
|
|
|
var isStarted = false |
|
|
|
var isStarted = false |
|
|
|
|
|
|
|
var isLongPress = false |
|
|
|
|
|
|
|
|
|
|
|
protected fun setStartPoint(x: Float, y: Float, invalidate: Boolean = true) { |
|
|
|
protected fun setStartPoint(x: Float, y: Float, invalidate: Boolean = true) { |
|
|
|
startX = x |
|
|
|
startX = x |
|
|
@ -154,14 +155,21 @@ abstract class PageDelegate(protected val pageView: PageView) { |
|
|
|
|
|
|
|
|
|
|
|
fun onTouch(event: MotionEvent): Boolean { |
|
|
|
fun onTouch(event: MotionEvent): Boolean { |
|
|
|
if (isStarted) return false |
|
|
|
if (isStarted) return false |
|
|
|
|
|
|
|
if (curPage?.isTextSelected() == true) { |
|
|
|
if (isMoved && event.action == MotionEvent.ACTION_UP) { |
|
|
|
curPage?.dispatchTouchEvent(event) |
|
|
|
// 开启翻页效果 |
|
|
|
|
|
|
|
if (!noNext) { |
|
|
|
|
|
|
|
onScrollStart() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (event.action == MotionEvent.ACTION_DOWN) { |
|
|
|
|
|
|
|
curPage?.contentTextView()?.setTextIsSelectable(true) |
|
|
|
|
|
|
|
curPage?.dispatchTouchEvent(event) |
|
|
|
|
|
|
|
} else if (event.action == MotionEvent.ACTION_UP) { |
|
|
|
|
|
|
|
curPage?.dispatchTouchEvent(event) |
|
|
|
|
|
|
|
if (isMoved) { |
|
|
|
|
|
|
|
// 开启翻页效果 |
|
|
|
|
|
|
|
if (!noNext) onScrollStart() |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return detector.onTouchEvent(event) |
|
|
|
return detector.onTouchEvent(event) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -182,6 +190,7 @@ abstract class PageDelegate(protected val pageView: PageView) { |
|
|
|
private inner class GestureListener : GestureDetector.SimpleOnGestureListener() { |
|
|
|
private inner class GestureListener : GestureDetector.SimpleOnGestureListener() { |
|
|
|
|
|
|
|
|
|
|
|
override fun onDown(e: MotionEvent): Boolean { |
|
|
|
override fun onDown(e: MotionEvent): Boolean { |
|
|
|
|
|
|
|
isLongPress = false |
|
|
|
// abort() |
|
|
|
// abort() |
|
|
|
//是否移动 |
|
|
|
//是否移动 |
|
|
|
isMoved = false |
|
|
|
isMoved = false |
|
|
@ -229,7 +238,13 @@ abstract class PageDelegate(protected val pageView: PageView) { |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onLongPress(e: MotionEvent?) { |
|
|
|
|
|
|
|
curPage?.dispatchTouchEvent(e) |
|
|
|
|
|
|
|
isLongPress = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onScroll(e1: MotionEvent, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean { |
|
|
|
override fun onScroll(e1: MotionEvent, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean { |
|
|
|
|
|
|
|
curPage?.contentTextView()?.setTextIsSelectable(false) |
|
|
|
if (!isMoved && abs(distanceX) > abs(distanceY)) { |
|
|
|
if (!isMoved && abs(distanceX) > abs(distanceY)) { |
|
|
|
if (distanceX < 0) { |
|
|
|
if (distanceX < 0) { |
|
|
|
//上一页的参数配置 |
|
|
|
//上一页的参数配置 |
|
|
|