@@ -64,6 +64,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
6464 private var mIsBucketFillOn = false
6565 private var mWasMultitouch = false
6666 private var mIgnoreTouches = false
67+ private var mIgnoreMultitouchChanges = false
6768 private var mWasScalingInGesture = false
6869 private var mWasMovingCanvasInGesture = false
6970 private var mBackgroundColor = 0
@@ -168,7 +169,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
168169 actionMove(newValueX, newValueY)
169170 }
170171
171- if (mAllowMovingZooming && mWasMultitouch) {
172+ if (mAllowMovingZooming && mWasMultitouch && ! mIgnoreMultitouchChanges ) {
172173 mPosX + = x - mLastTouchX
173174 mPosY + = y - mLastTouchY
174175 mWasMovingCanvasInGesture = true
@@ -177,6 +178,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
177178
178179 mLastTouchX = x
179180 mLastTouchY = y
181+ mIgnoreMultitouchChanges = false
180182 }
181183 MotionEvent .ACTION_UP , MotionEvent .ACTION_CANCEL -> {
182184 mActivePointerId = INVALID_POINTER_ID
@@ -187,12 +189,14 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
187189 MotionEvent .ACTION_POINTER_DOWN -> {
188190 if (mAllowMovingZooming) {
189191 mWasMultitouch = true
192+ mIgnoreMultitouchChanges = true
190193 mTouchSloppedBeforeMultitouch = mLastMotionEvent.isTouchSlop(pointerIndex, mStartX, mStartY)
191194 }
192195 }
193196 MotionEvent .ACTION_POINTER_UP -> {
194197 if (mAllowMovingZooming) {
195198 mIgnoreTouches = true
199+ mIgnoreMultitouchChanges = true
196200 actionUp(! mWasScalingInGesture && ! mWasMovingCanvasInGesture)
197201 }
198202 }
0 commit comments