mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:55:00 +08:00
滚动阅读时,多指触摸造成闪烁的问题
This commit is contained in:
parent
ed35e1749f
commit
982a0d8e45
@ -27,10 +27,7 @@ import io.legado.app.ui.book.read.page.entities.TextPage
|
|||||||
import io.legado.app.ui.book.read.page.entities.TextPos
|
import io.legado.app.ui.book.read.page.entities.TextPos
|
||||||
import io.legado.app.ui.book.read.page.provider.ChapterProvider
|
import io.legado.app.ui.book.read.page.provider.ChapterProvider
|
||||||
import io.legado.app.ui.book.read.page.provider.TextPageFactory
|
import io.legado.app.ui.book.read.page.provider.TextPageFactory
|
||||||
import io.legado.app.utils.activity
|
import io.legado.app.utils.*
|
||||||
import io.legado.app.utils.invisible
|
|
||||||
import io.legado.app.utils.screenshot
|
|
||||||
import io.legado.app.utils.showDialogFragment
|
|
||||||
import java.text.BreakIterator
|
import java.text.BreakIterator
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
@ -184,6 +181,15 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//在多点触控时,事件不走ACTION_DOWN分支而产生的特殊事件处理
|
||||||
|
if (event.actionMasked == MotionEvent.ACTION_POINTER_DOWN){
|
||||||
|
//当多个手指同时按下的情况,将最后一个按下的手指的坐标设置为起始坐标,所以只有最后一个手指的滑动事件被处理
|
||||||
|
setStartPoint(event.getX(event.pointerCount - 1), event.getY(event.pointerCount - 1), false)
|
||||||
|
} else if(event.actionMasked == MotionEvent.ACTION_POINTER_UP){
|
||||||
|
//当多个手指同时按下的情况,当抬起一个手指时,起始坐标恢复为第一次按下的手指的坐标
|
||||||
|
setStartPoint(event.x, event.y, false)
|
||||||
|
return true
|
||||||
|
}
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
callBack.screenOffTimerStart()
|
callBack.screenOffTimerStart()
|
||||||
|
@ -58,10 +58,14 @@ class ScrollPageDelegate(readView: ReadView) : PageDelegate(readView) {
|
|||||||
private fun onScroll(event: MotionEvent) {
|
private fun onScroll(event: MotionEvent) {
|
||||||
mVelocity.addMovement(event)
|
mVelocity.addMovement(event)
|
||||||
mVelocity.computeCurrentVelocity(velocityDuration)
|
mVelocity.computeCurrentVelocity(velocityDuration)
|
||||||
readView.setTouchPoint(event.getX(0), event.getY(0))
|
//取最后添加(即最新的)一个触摸点来计算滚动位置
|
||||||
|
//多点触控时即最后按下的手指产生的事件点
|
||||||
|
val pointX = event.getX(event.pointerCount - 1)
|
||||||
|
val pointY = event.getY(event.pointerCount - 1)
|
||||||
|
readView.setTouchPoint(pointX, pointY)
|
||||||
if (!isMoved) {
|
if (!isMoved) {
|
||||||
val deltaX = (event.getX(0) - startX).toInt()
|
val deltaX = (pointX - startX).toInt()
|
||||||
val deltaY = (event.getY(0) - startY).toInt()
|
val deltaY = (pointY - startY).toInt()
|
||||||
val distance = deltaX * deltaX + deltaY * deltaY
|
val distance = deltaX * deltaX + deltaY * deltaY
|
||||||
isMoved = distance > readView.slopSquare
|
isMoved = distance > readView.slopSquare
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user