|
|
@ -23,7 +23,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 |
|
|
|
protected val slop = ViewConfiguration.get(context).scaledTouchSlop |
|
|
|
|
|
|
|
//起始点 |
|
|
|
//起始点 |
|
|
|
protected var startX: Float = 0f |
|
|
|
protected var startX: Float = 0f |
|
|
|
protected var startY: Float = 0f |
|
|
|
protected var startY: Float = 0f |
|
|
@ -41,18 +41,23 @@ abstract class PageDelegate(protected val pageView: PageView) : |
|
|
|
protected var viewWidth: Int = pageView.width |
|
|
|
protected var viewWidth: Int = pageView.width |
|
|
|
protected var viewHeight: Int = pageView.height |
|
|
|
protected var viewHeight: Int = pageView.height |
|
|
|
|
|
|
|
|
|
|
|
private val snackBar: Snackbar by lazy { |
|
|
|
|
|
|
|
Snackbar.make(pageView, "", Snackbar.LENGTH_SHORT) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val scroller: Scroller by lazy { |
|
|
|
private val scroller: Scroller by lazy { |
|
|
|
Scroller(pageView.context, DecelerateInterpolator()) |
|
|
|
Scroller(pageView.context, DecelerateInterpolator()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected val slopSquare by lazy { |
|
|
|
|
|
|
|
val scaledTouchSlop = ViewConfiguration.get(context).scaledTouchSlop |
|
|
|
|
|
|
|
scaledTouchSlop * scaledTouchSlop |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private val detector: GestureDetector by lazy { |
|
|
|
private val detector: GestureDetector by lazy { |
|
|
|
GestureDetector(pageView.context, this) |
|
|
|
GestureDetector(pageView.context, this) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val snackBar: Snackbar by lazy { |
|
|
|
|
|
|
|
Snackbar.make(pageView, "", Snackbar.LENGTH_SHORT) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var isMoved = false |
|
|
|
var isMoved = false |
|
|
|
var noNext = true |
|
|
|
var noNext = true |
|
|
|
|
|
|
|
|
|
|
@ -189,6 +194,7 @@ abstract class PageDelegate(protected val pageView: PageView) : |
|
|
|
@CallSuper |
|
|
|
@CallSuper |
|
|
|
open fun onTouch(event: MotionEvent) { |
|
|
|
open fun onTouch(event: MotionEvent) { |
|
|
|
if (isStarted) return |
|
|
|
if (isStarted) return |
|
|
|
|
|
|
|
detector.setIsLongpressEnabled(false) |
|
|
|
if (!detector.onTouchEvent(event)) { |
|
|
|
if (!detector.onTouchEvent(event)) { |
|
|
|
//GestureDetector.onFling小幅移动不会触发,所以要自己判断 |
|
|
|
//GestureDetector.onFling小幅移动不会触发,所以要自己判断 |
|
|
|
when (event.action) { |
|
|
|
when (event.action) { |
|
|
|