|
|
@ -16,27 +16,11 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { |
|
|
|
shadowDrawableR.gradientType = GradientDrawable.LINEAR_GRADIENT |
|
|
|
shadowDrawableR.gradientType = GradientDrawable.LINEAR_GRADIENT |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onAnimStart() { |
|
|
|
override fun setStartPoint(x: Float, y: Float, invalidate: Boolean) { |
|
|
|
val distanceX: Float |
|
|
|
curPage.x = 0.toFloat() |
|
|
|
when (mDirection) { |
|
|
|
prevPage.x = -viewWidth.toFloat() |
|
|
|
Direction.NEXT -> distanceX = |
|
|
|
nextPage.x = 0.toFloat() |
|
|
|
if (isCancel) { |
|
|
|
super.setStartPoint(x, y, invalidate) |
|
|
|
var dis = viewWidth - startX + touchX |
|
|
|
|
|
|
|
if (dis > viewWidth) { |
|
|
|
|
|
|
|
dis = viewWidth.toFloat() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
viewWidth - dis |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
-(touchX + (viewWidth - startX)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> distanceX = |
|
|
|
|
|
|
|
if (isCancel) { |
|
|
|
|
|
|
|
-(touchX - startX) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
viewWidth - (touchX - startX) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
startScroll(touchX.toInt(), 0, distanceX.toInt(), 0) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onDraw(canvas: Canvas) { |
|
|
|
override fun onDraw(canvas: Canvas) { |
|
|
@ -47,7 +31,7 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { |
|
|
|
) return |
|
|
|
) return |
|
|
|
|
|
|
|
|
|
|
|
val distanceX = if (offsetX > 0) offsetX - viewWidth else offsetX + viewWidth |
|
|
|
val distanceX = if (offsetX > 0) offsetX - viewWidth else offsetX + viewWidth |
|
|
|
if (!isMoved) return |
|
|
|
if (!isRunning) return |
|
|
|
if (mDirection == Direction.PREV) { |
|
|
|
if (mDirection == Direction.PREV) { |
|
|
|
prevPage.translationX = offsetX - viewWidth |
|
|
|
prevPage.translationX = offsetX - viewWidth |
|
|
|
} else if (mDirection == Direction.NEXT) { |
|
|
|
} else if (mDirection == Direction.NEXT) { |
|
|
@ -74,4 +58,27 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onAnimStart() { |
|
|
|
|
|
|
|
val distanceX: Float |
|
|
|
|
|
|
|
when (mDirection) { |
|
|
|
|
|
|
|
Direction.NEXT -> distanceX = |
|
|
|
|
|
|
|
if (isCancel) { |
|
|
|
|
|
|
|
var dis = viewWidth - startX + touchX |
|
|
|
|
|
|
|
if (dis > viewWidth) { |
|
|
|
|
|
|
|
dis = viewWidth.toFloat() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
viewWidth - dis |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
-(touchX + (viewWidth - startX)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> distanceX = |
|
|
|
|
|
|
|
if (isCancel) { |
|
|
|
|
|
|
|
-(touchX - startX) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
viewWidth - (touchX - startX) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
startScroll(touchX.toInt(), 0, distanceX.toInt(), 0) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|