feat: 优化代码

pull/105/head
kunfei 5 years ago
parent 14f7979175
commit 5b8174d644
  1. 11
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt

@ -86,8 +86,6 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi
override fun setStartPoint(x: Float, y: Float, invalidate: Boolean) { override fun setStartPoint(x: Float, y: Float, invalidate: Boolean) {
super.setStartPoint(x, y, invalidate) super.setStartPoint(x, y, invalidate)
mTouchX = x
mTouchY = y
calcCornerXY(x, y) calcCornerXY(x, y)
} }
@ -97,13 +95,13 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi
if ((startY > viewHeight * 0.33 && startY < viewHeight * 0.66) if ((startY > viewHeight * 0.33 && startY < viewHeight * 0.66)
|| mDirection == Direction.PREV || mDirection == Direction.PREV
) { ) {
mTouchY = viewHeight.toFloat() touchY = viewHeight.toFloat()
} }
if (startY > viewHeight * 0.33 && startY < viewHeight / 2.0 if (startY > viewHeight * 0.33 && startY < viewHeight / 2.0
&& mDirection == Direction.NEXT && mDirection == Direction.NEXT
) { ) {
mTouchY = 1f touchY = 1f
} }
} }
@ -355,10 +353,7 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi
} }
var rotateDegrees: Float = var rotateDegrees: Float =
Math.toDegrees( Math.toDegrees(
atan2( atan2(mTouchX - mBezierControl1.x, mBezierControl1.y - mTouchY).toDouble()
mTouchX - mBezierControl1.x,
mBezierControl1.y - mTouchY
).toDouble()
) )
.toFloat() .toFloat()
canvas.rotate(rotateDegrees, mBezierControl1.x, mBezierControl1.y) canvas.rotate(rotateDegrees, mBezierControl1.x, mBezierControl1.y)

Loading…
Cancel
Save