feat: 优化代码

pull/117/head
kunfei 5 years ago
parent 438647f43e
commit ad6a56239e
  1. 2
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt

@ -136,7 +136,7 @@ abstract class PageDelegate(protected val pageView: PageView) :
bitmap = null
}
fun setViewSize(width: Int, height: Int) {
open fun setViewSize(width: Int, height: Int) {
viewWidth = width
viewHeight = height
pageView.invalidate()

@ -115,6 +115,11 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi
mFrontShadowDrawableHBT.gradientType = GradientDrawable.LINEAR_GRADIENT
}
override fun setViewSize(width: Int, height: Int) {
super.setViewSize(width, height)
mMaxLength = hypot(viewWidth.toDouble(), viewWidth.toDouble()).toFloat()
}
override fun setStartPoint(x: Float, y: Float, invalidate: Boolean) {
super.setStartPoint(x, y, invalidate)
calcCornerXY(x, y)
@ -171,7 +176,6 @@ class SimulationPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageVi
override fun onAnimStart() {
var dx: Float
val dy: Float
// dx 水平方向滑动的距离,负值会使滚动向左滚动
// dy 垂直方向滑动的距离,负值会使滚动向上滚动
if (isCancel) {
dx = if (mCornerX > 0 && mDirection == Direction.NEXT) {

Loading…
Cancel
Save