File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -482,6 +482,27 @@ public boolean onTouchEvent(MotionEvent ev) {
482482 case MotionEvent .ACTION_POINTER_UP :
483483 mDownFocusX = mLastFocusX = focusX ;
484484 mDownFocusY = mLastFocusY = focusY ;
485+
486+ // Check the dot product of current velocities.
487+ // If the pointer that left was opposing another velocity vector, clear.
488+ mVelocityTracker .computeCurrentVelocity (1000 , mMaximumFlingVelocity );
489+ final int upIndex = ev .getActionIndex ();
490+ final int id1 = ev .getPointerId (upIndex );
491+ final float x1 = mVelocityTracker .getXVelocity (id1 );
492+ final float y1 = mVelocityTracker .getYVelocity (id1 );
493+ for (int i = 0 ; i < count ; i ++) {
494+ if (i == upIndex ) continue ;
495+
496+ final int id2 = ev .getPointerId (i );
497+ final float x = x1 * mVelocityTracker .getXVelocity (id2 );
498+ final float y = y1 * mVelocityTracker .getYVelocity (id2 );
499+
500+ final float dot = x + y ;
501+ if (dot < 0 ) {
502+ mVelocityTracker .clear ();
503+ break ;
504+ }
505+ }
485506 break ;
486507
487508 case MotionEvent .ACTION_DOWN :
You can’t perform that action at this time.
0 commit comments