|
|
@ -6,6 +6,7 @@ import android.os.Build |
|
|
|
import android.view.MotionEvent |
|
|
|
import android.view.MotionEvent |
|
|
|
import io.legado.app.help.ReadBookConfig |
|
|
|
import io.legado.app.help.ReadBookConfig |
|
|
|
import io.legado.app.ui.book.read.page.PageView |
|
|
|
import io.legado.app.ui.book.read.page.PageView |
|
|
|
|
|
|
|
import io.legado.app.ui.book.read.page.entities.PageDirection |
|
|
|
import kotlin.math.* |
|
|
|
import kotlin.math.* |
|
|
|
|
|
|
|
|
|
|
|
@Suppress("DEPRECATION") |
|
|
|
@Suppress("DEPRECATION") |
|
|
@ -123,13 +124,13 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi |
|
|
|
} |
|
|
|
} |
|
|
|
MotionEvent.ACTION_MOVE -> { |
|
|
|
MotionEvent.ACTION_MOVE -> { |
|
|
|
if ((startY > viewHeight / 3 && startY < viewHeight * 2 / 3) |
|
|
|
if ((startY > viewHeight / 3 && startY < viewHeight * 2 / 3) |
|
|
|
|| mDirection == Direction.PREV |
|
|
|
|| mDirection == PageDirection.PREV |
|
|
|
) { |
|
|
|
) { |
|
|
|
pageView.touchY = viewHeight.toFloat() |
|
|
|
pageView.touchY = viewHeight.toFloat() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (startY > viewHeight / 3 && startY < viewHeight / 2 |
|
|
|
if (startY > viewHeight / 3 && startY < viewHeight / 2 |
|
|
|
&& mDirection == Direction.NEXT |
|
|
|
&& mDirection == PageDirection.NEXT |
|
|
|
) { |
|
|
|
) { |
|
|
|
pageView.touchY = 1f |
|
|
|
pageView.touchY = 1f |
|
|
|
} |
|
|
|
} |
|
|
@ -137,17 +138,17 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun setDirection(direction: Direction) { |
|
|
|
override fun setDirection(direction: PageDirection) { |
|
|
|
super.setDirection(direction) |
|
|
|
super.setDirection(direction) |
|
|
|
when (direction) { |
|
|
|
when (direction) { |
|
|
|
Direction.PREV -> |
|
|
|
PageDirection.PREV -> |
|
|
|
//上一页滑动不出现对角 |
|
|
|
//上一页滑动不出现对角 |
|
|
|
if (startX > viewWidth / 2) { |
|
|
|
if (startX > viewWidth / 2) { |
|
|
|
calcCornerXY(startX, viewHeight.toFloat()) |
|
|
|
calcCornerXY(startX, viewHeight.toFloat()) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
calcCornerXY(viewWidth - startX, viewHeight.toFloat()) |
|
|
|
calcCornerXY(viewWidth - startX, viewHeight.toFloat()) |
|
|
|
} |
|
|
|
} |
|
|
|
Direction.NEXT -> |
|
|
|
PageDirection.NEXT -> |
|
|
|
if (viewWidth / 2 > startX) { |
|
|
|
if (viewWidth / 2 > startX) { |
|
|
|
calcCornerXY(viewWidth - startX, startY) |
|
|
|
calcCornerXY(viewWidth - startX, startY) |
|
|
|
} |
|
|
|
} |
|
|
@ -160,12 +161,12 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi |
|
|
|
val dy: Float |
|
|
|
val dy: Float |
|
|
|
// dy 垂直方向滑动的距离,负值会使滚动向上滚动 |
|
|
|
// dy 垂直方向滑动的距离,负值会使滚动向上滚动 |
|
|
|
if (isCancel) { |
|
|
|
if (isCancel) { |
|
|
|
dx = if (mCornerX > 0 && mDirection == Direction.NEXT) { |
|
|
|
dx = if (mCornerX > 0 && mDirection == PageDirection.NEXT) { |
|
|
|
(viewWidth - touchX) |
|
|
|
(viewWidth - touchX) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
-touchX |
|
|
|
-touchX |
|
|
|
} |
|
|
|
} |
|
|
|
if (mDirection != Direction.NEXT) { |
|
|
|
if (mDirection != PageDirection.NEXT) { |
|
|
|
dx = -(viewWidth + touchX) |
|
|
|
dx = -(viewWidth + touchX) |
|
|
|
} |
|
|
|
} |
|
|
|
dy = if (mCornerY > 0) { |
|
|
|
dy = if (mCornerY > 0) { |
|
|
@ -174,7 +175,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi |
|
|
|
-touchY // 防止mTouchY最终变为0 |
|
|
|
-touchY // 防止mTouchY最终变为0 |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
dx = if (mCornerX > 0 && mDirection == Direction.NEXT) { |
|
|
|
dx = if (mCornerX > 0 && mDirection == PageDirection.NEXT) { |
|
|
|
-(viewWidth + touchX) |
|
|
|
-(viewWidth + touchX) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
(viewWidth - touchX + viewWidth) |
|
|
|
(viewWidth - touchX + viewWidth) |
|
|
@ -197,14 +198,14 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi |
|
|
|
override fun onDraw(canvas: Canvas) { |
|
|
|
override fun onDraw(canvas: Canvas) { |
|
|
|
if (!isRunning) return |
|
|
|
if (!isRunning) return |
|
|
|
when (mDirection) { |
|
|
|
when (mDirection) { |
|
|
|
Direction.NEXT -> { |
|
|
|
PageDirection.NEXT -> { |
|
|
|
calcPoints() |
|
|
|
calcPoints() |
|
|
|
drawCurrentPageArea(canvas, curBitmap) |
|
|
|
drawCurrentPageArea(canvas, curBitmap) |
|
|
|
drawNextPageAreaAndShadow(canvas, nextBitmap) |
|
|
|
drawNextPageAreaAndShadow(canvas, nextBitmap) |
|
|
|
drawCurrentPageShadow(canvas) |
|
|
|
drawCurrentPageShadow(canvas) |
|
|
|
drawCurrentBackArea(canvas, curBitmap) |
|
|
|
drawCurrentBackArea(canvas, curBitmap) |
|
|
|
} |
|
|
|
} |
|
|
|
Direction.PREV -> { |
|
|
|
PageDirection.PREV -> { |
|
|
|
calcPoints() |
|
|
|
calcPoints() |
|
|
|
drawCurrentPageArea(canvas, prevBitmap) |
|
|
|
drawCurrentPageArea(canvas, prevBitmap) |
|
|
|
drawNextPageAreaAndShadow(canvas, curBitmap) |
|
|
|
drawNextPageAreaAndShadow(canvas, curBitmap) |
|
|
|