pull/478/head
gedoor 4 years ago
parent d47d43df38
commit dbe5c7507b
  1. 54
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -72,15 +72,15 @@ class PageView(context: Context, attrs: AttributeSet) :
private var firstCharIndex: Int = 0 private var firstCharIndex: Int = 0
val slopSquare by lazy { ViewConfiguration.get(context).scaledTouchSlop } val slopSquare by lazy { ViewConfiguration.get(context).scaledTouchSlop }
private val tlRectF = RectF(10F, 10F, width * 0.33f, height * 0.33f) private val tlRect = RectF(10F, 10F, width * 0.33f, height * 0.33f)
private val tcRectF = RectF(width * 0.33f, 10F, width * 0.66f, height * 0.33f) private val tcRect = RectF(width * 0.33f, 10F, width * 0.66f, height * 0.33f)
private val trRectF = RectF(width * 0.36f, 10F, width - 10f, height * 0.33f) private val trRect = RectF(width * 0.36f, 10F, width - 10f, height * 0.33f)
private val mlRectF = RectF(10F, height * 0.33f, width * 0.33f, height * 0.66f) private val mlRect = RectF(10F, height * 0.33f, width * 0.33f, height * 0.66f)
private val mcRectF = RectF(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f) private val mcRect = RectF(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f)
private val mrRectF = RectF(width * 0.66f, height * 0.33f, width - 10f, height * 0.66f) private val mrRect = RectF(width * 0.66f, height * 0.33f, width - 10f, height * 0.66f)
private val blRectF = RectF(10F, height * 0.66f, width * 0.33f, height - 10f) private val blRect = RectF(10F, height * 0.66f, width * 0.33f, height - 10f)
private val bcRectF = RectF(width * 0.33f, height * 0.66f, width * 0.66f, height - 10f) private val bcRect = RectF(width * 0.33f, height * 0.66f, width * 0.66f, height - 10f)
private val brRectF = RectF(width * 0.66f, height * 0.66f, width - 10f, height - 10f) private val brRect = RectF(width * 0.66f, height * 0.66f, width - 10f, height - 10f)
private val autoPageRect by lazy { private val autoPageRect by lazy {
Rect() Rect()
} }
@ -101,15 +101,15 @@ class PageView(context: Context, attrs: AttributeSet) :
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh) super.onSizeChanged(w, h, oldw, oldh)
tlRectF.set(10F, 10F, width * 0.33f, height * 0.33f) tlRect.set(10F, 10F, width * 0.33f, height * 0.33f)
tcRectF.set(width * 0.33f, 10F, width * 0.66f, height * 0.33f) tcRect.set(width * 0.33f, 10F, width * 0.66f, height * 0.33f)
trRectF.set(width * 0.36f, 10F, width - 10f, height * 0.33f) trRect.set(width * 0.36f, 10F, width - 10f, height * 0.33f)
mlRectF.set(10F, height * 0.33f, width * 0.33f, height * 0.66f) mlRect.set(10F, height * 0.33f, width * 0.33f, height * 0.66f)
mcRectF.set(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f) mcRect.set(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f)
mrRectF.set(width * 0.66f, height * 0.33f, width - 10f, height * 0.66f) mrRect.set(width * 0.66f, height * 0.33f, width - 10f, height * 0.66f)
blRectF.set(10F, height * 0.66f, width * 0.33f, height - 10f) blRect.set(10F, height * 0.66f, width * 0.33f, height - 10f)
bcRectF.set(width * 0.33f, height * 0.66f, width * 0.66f, height - 10f) bcRect.set(width * 0.33f, height * 0.66f, width * 0.66f, height - 10f)
brRectF.set(width * 0.66f, height * 0.66f, width - 10f, height - 10f) brRect.set(width * 0.66f, height * 0.66f, width - 10f, height - 10f)
prevPage.x = -w.toFloat() prevPage.x = -w.toFloat()
pageDelegate?.setViewSize(w, h) pageDelegate?.setViewSize(w, h)
if (oldw != 0 && oldh != 0) { if (oldw != 0 && oldh != 0) {
@ -260,31 +260,31 @@ class PageView(context: Context, attrs: AttributeSet) :
private fun onSingleTapUp(): Boolean { private fun onSingleTapUp(): Boolean {
when { when {
isTextSelected -> isTextSelected = false isTextSelected -> isTextSelected = false
mcRectF.contains(startX, startY) -> if (!isAbortAnim) { mcRect.contains(startX, startY) -> if (!isAbortAnim) {
click(AppConfig.clickActionMiddleCenter) click(AppConfig.clickActionMiddleCenter)
} }
bcRectF.contains(startX, startY) -> { bcRect.contains(startX, startY) -> {
click(AppConfig.clickActionBottomCenter) click(AppConfig.clickActionBottomCenter)
} }
blRectF.contains(startX, startY) -> { blRect.contains(startX, startY) -> {
click(AppConfig.clickActionBottomLeft) click(AppConfig.clickActionBottomLeft)
} }
brRectF.contains(startX, startY) -> { brRect.contains(startX, startY) -> {
click(AppConfig.clickActionBottomRight) click(AppConfig.clickActionBottomRight)
} }
mlRectF.contains(startX, startY) -> { mlRect.contains(startX, startY) -> {
click(AppConfig.clickActionMiddleLeft) click(AppConfig.clickActionMiddleLeft)
} }
mrRectF.contains(startX, startY) -> { mrRect.contains(startX, startY) -> {
click(AppConfig.clickActionMiddleRight) click(AppConfig.clickActionMiddleRight)
} }
tlRectF.contains(startX, startY) -> { tlRect.contains(startX, startY) -> {
click(AppConfig.clickActionTopLeft) click(AppConfig.clickActionTopLeft)
} }
tcRectF.contains(startX, startY) -> { tcRect.contains(startX, startY) -> {
click(AppConfig.clickActionTopCenter) click(AppConfig.clickActionTopCenter)
} }
trRectF.contains(startX, startY) -> { trRect.contains(startX, startY) -> {
click(AppConfig.clickActionTopRight) click(AppConfig.clickActionTopRight)
} }
} }

Loading…
Cancel
Save