mirror of
https://github.com/SimpleMobileTools/Simple-Draw.git
synced 2025-04-23 23:07:18 +02:00
fixing a glitch with some lines being drawn at move gestures
This commit is contained in:
parent
24328a3812
commit
cf05bbad91
@ -58,6 +58,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
private var mWasMultitouch = false
|
private var mWasMultitouch = false
|
||||||
private var mIgnoreTouches = false
|
private var mIgnoreTouches = false
|
||||||
private var mWasScalingInGesture = false
|
private var mWasScalingInGesture = false
|
||||||
|
private var mWasMovingCanvasInGesture = false
|
||||||
private var mBackgroundColor = 0
|
private var mBackgroundColor = 0
|
||||||
private var mCenter: PointF? = null
|
private var mCenter: PointF? = null
|
||||||
|
|
||||||
@ -108,6 +109,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
if (mIgnoreTouches && action == MotionEvent.ACTION_UP) {
|
if (mIgnoreTouches && action == MotionEvent.ACTION_UP) {
|
||||||
mIgnoreTouches = false
|
mIgnoreTouches = false
|
||||||
mWasScalingInGesture = false
|
mWasScalingInGesture = false
|
||||||
|
mWasMovingCanvasInGesture = false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +145,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
when (action) {
|
when (action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
mWasScalingInGesture = false
|
mWasScalingInGesture = false
|
||||||
|
mWasMovingCanvasInGesture = false
|
||||||
mWasMultitouch = false
|
mWasMultitouch = false
|
||||||
mStartX = x
|
mStartX = x
|
||||||
mStartY = y
|
mStartY = y
|
||||||
@ -165,6 +168,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
if (mAllowMovingZooming && mWasMultitouch) {
|
if (mAllowMovingZooming && mWasMultitouch) {
|
||||||
mPosX += x - mLastTouchX
|
mPosX += x - mLastTouchX
|
||||||
mPosY += y - mLastTouchY
|
mPosY += y - mLastTouchY
|
||||||
|
mWasMovingCanvasInGesture = true
|
||||||
invalidate()
|
invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +179,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
mActivePointerId = INVALID_POINTER_ID
|
mActivePointerId = INVALID_POINTER_ID
|
||||||
actionUp(false)
|
actionUp(false)
|
||||||
mWasScalingInGesture = false
|
mWasScalingInGesture = false
|
||||||
|
mWasMovingCanvasInGesture = false
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_POINTER_DOWN -> {
|
MotionEvent.ACTION_POINTER_DOWN -> {
|
||||||
mWasMultitouch = true
|
mWasMultitouch = true
|
||||||
@ -182,12 +187,11 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||||||
}
|
}
|
||||||
MotionEvent.ACTION_POINTER_UP -> {
|
MotionEvent.ACTION_POINTER_UP -> {
|
||||||
mIgnoreTouches = true
|
mIgnoreTouches = true
|
||||||
actionUp(!mWasScalingInGesture)
|
actionUp(!mWasScalingInGesture && !mWasMovingCanvasInGesture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mLastMotionEvent = MotionEvent.obtain(event)
|
mLastMotionEvent = MotionEvent.obtain(event)
|
||||||
|
|
||||||
invalidate()
|
invalidate()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user