@@ -60,6 +60,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
6060 private var mIsBucketFillOn = false
6161 private var mWasMultitouch = false
6262 private var mIgnoreTouches = false
63+ private var mIgnoreMultitouchChanges = false
6364 private var mWasScalingInGesture = false
6465 private var mWasMovingCanvasInGesture = false
6566 private var mBackgroundColor = 0
@@ -160,7 +161,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
160161 actionMove(newValueX, newValueY)
161162 }
162163
163- if (mAllowMovingZooming && mWasMultitouch) {
164+ if (mAllowMovingZooming && mWasMultitouch && ! mIgnoreMultitouchChanges ) {
164165 mPosX + = x - mLastTouchX
165166 mPosY + = y - mLastTouchY
166167 mWasMovingCanvasInGesture = true
@@ -169,6 +170,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
169170
170171 mLastTouchX = x
171172 mLastTouchY = y
173+ mIgnoreMultitouchChanges = false
172174 }
173175 MotionEvent .ACTION_UP , MotionEvent .ACTION_CANCEL -> {
174176 mActivePointerId = INVALID_POINTER_ID
@@ -179,12 +181,14 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
179181 MotionEvent .ACTION_POINTER_DOWN -> {
180182 if (mAllowMovingZooming) {
181183 mWasMultitouch = true
184+ mIgnoreMultitouchChanges = true
182185 mTouchSloppedBeforeMultitouch = mLastMotionEvent.isTouchSlop(pointerIndex, mStartX, mStartY)
183186 }
184187 }
185188 MotionEvent .ACTION_POINTER_UP -> {
186189 if (mAllowMovingZooming) {
187190 mIgnoreTouches = true
191+ mIgnoreMultitouchChanges = true
188192 actionUp(! mWasScalingInGesture && ! mWasMovingCanvasInGesture)
189193 }
190194 }
0 commit comments