Code example for MotionEvent

Methods: findPointerIndexgetXgetY

0
             */ 
            return touchState != TOUCH_STATE_REST;
        } 
 
        private void handleInterceptMove(MotionEvent ev) {
            final int pointerIndex = ev.findPointerIndex(mActivePointerId);
            final float x = ev.getX(pointerIndex);
            final float y = ev.getY(pointerIndex);
            final int xDiff = (int) Math.abs(x - lastMotionX);
            final int yDiff = (int) Math.abs(y - lastMotionY);
            boolean xMoved = xDiff > touchSlop;
            boolean yMoved = yDiff > touchSlop;
 
            if (xMoved || yMoved) {
                //Log.d("workspace","Detected move.  Checking to scroll."); 
                if (xMoved && !yMoved) {
                    //Log.d("workspace","Detected X move.  Scrolling."); 
                    // Scroll if the user moved far enough along the X axis 
                    touchState = TOUCH_STATE_SCROLLING;
                    lastMotionX = x;
                }