feat: 优化代码

pull/111/head
kunfei 5 years ago
parent 577bd6a83b
commit 0f88499063
  1. 8
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  2. 9
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt

@ -1,11 +1,9 @@
package io.legado.app.ui.book.read.page package io.legado.app.ui.book.read.page
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.graphics.Canvas import android.graphics.Canvas
import android.graphics.Paint import android.graphics.Paint
import android.util.AttributeSet import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View import android.view.View
import io.legado.app.R import io.legado.app.R
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
@ -51,12 +49,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
} }
} }
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent?): Boolean {
return true
}
override fun onDraw(canvas: Canvas) { override fun onDraw(canvas: Canvas) {
super.onDraw(canvas) super.onDraw(canvas)
textPage?.let { textPage -> textPage?.let { textPage ->

@ -211,7 +211,6 @@ abstract class PageDelegate(protected val pageView: PageView) :
@CallSuper @CallSuper
open fun onTouch(event: MotionEvent): Boolean { open fun onTouch(event: MotionEvent): Boolean {
if (isStarted) return false if (isStarted) return false
curPage.dispatchTouchEvent(event)
return detector.onTouchEvent(event) return detector.onTouchEvent(event)
} }
@ -222,7 +221,6 @@ abstract class PageDelegate(protected val pageView: PageView) :
if (isTextSelected) { if (isTextSelected) {
curPage.cancelSelect() curPage.cancelSelect()
} }
// abort()
//是否移动 //是否移动
isMoved = false isMoved = false
//是否存在下一章 //是否存在下一章
@ -242,6 +240,10 @@ abstract class PageDelegate(protected val pageView: PageView) :
* 单击 * 单击
*/ */
override fun onSingleTapUp(e: MotionEvent): Boolean { override fun onSingleTapUp(e: MotionEvent): Boolean {
if (isTextSelected) {
isTextSelected = false
return true
}
val x = e.x val x = e.x
val y = e.y val y = e.y
if (centerRectF.contains(x, y)) { if (centerRectF.contains(x, y)) {
@ -290,6 +292,9 @@ abstract class PageDelegate(protected val pageView: PageView) :
velocityX: Float, velocityX: Float,
velocityY: Float velocityY: Float
): Boolean { ): Boolean {
if (isTextSelected) {
isTextSelected = false
}
if (!noNext) onAnimStart() if (!noNext) onAnimStart()
return true return true
} }

Loading…
Cancel
Save