feat: 优化代码

pull/134/head^2
kunfei 5 years ago
parent 8ac44e200b
commit 2868b89c38
  1. 6
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt

@ -18,14 +18,16 @@ class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) {
}
override fun onDraw(canvas: Canvas) {
if (!isRunning) return
val offsetX = touchX - startX
if ((mDirection == Direction.NEXT && offsetX > 0)
|| (mDirection == Direction.PREV && offsetX < 0)
) return
) {
return
}
val distanceX = if (offsetX > 0) offsetX - viewWidth else offsetX + viewWidth
if (!isRunning) return
if (mDirection == Direction.PREV) {
bitmapMatrix.setTranslate(distanceX, 0.toFloat())
curBitmap?.let { canvas.drawBitmap(it, 0f, 0f, null) }

@ -128,9 +128,11 @@ abstract class PageDelegate(protected val pageView: PageView) :
private fun stopScroll() {
isMoved = false
isRunning = false
isStarted = false
pageView.invalidate()
pageView.post {
isRunning = false
pageView.invalidate()
}
}
open fun setViewSize(width: Int, height: Int) {

Loading…
Cancel
Save