compat/src/main/java/androidx/core/view/DragStartHelper.java
public boolean onTouch(View v, MotionEvent event) {
        final int x = (int) event.getX();
        final int y = (int) event.getY();
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                mLastTouchX = x;
                mLastTouchY = y;
                break;

            case MotionEvent.ACTION_MOVE:
                if (!MotionEventCompat.isFromSource(event, InputDeviceCompat.SOURCE_MOUSE)
                        || (event.getButtonState()
                                & MotionEvent.BUTTON_PRIMARY) == 0) {
                    break;
                }
                if (mDragging) {
                    // Ignore ACTION_MOVE events once the drag operation is in progress.
                    break;
                }
                if (mLastTouchX == x && mLastTouchY == y) {
                    // Do not call the listener unless the pointer position has actually changed.
                    break;
                }
                mLastTouchX = x;
                mLastTouchY = y;
                mDragging = mListener.onDragStart(v, this);
                return mDragging;

            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                mDragging = false;
                break;
        }
        return false;
    }
/**
     * Handle a touch event.
     * @param v The view the touch event has been dispatched to.
     * @param event The MotionEvent object containing full information about
     *        the event.
     * @return True if the listener has consumed the event, false otherwise.
     */
Handle a touch event.
@param v The view the touch event has been dispatched to.
@param event The MotionEvent object containing full information about
the event.
@return True if the listener has consumed the event, false otherwise.
Handle a touch event . @param v The view the touch event has been dispatched to . @param event The MotionEvent object containing full information about the event . @return True if the listener has consumed the event false otherwise .
public boolean onTouch(View v, MotionEvent event) {
        final int x = (int) event.getX();
        final int y = (int) event.getY();
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                mLastTouchX = x;
                mLastTouchY = y;
                break;
            case MotionEvent.ACTION_MOVE:
                if (!MotionEventCompat.isFromSource(event, InputDeviceCompat.SOURCE_MOUSE)
                        || (event.getButtonState()
                                & MotionEvent.BUTTON_PRIMARY) == 0) {
                    break;
                }
                if (mDragging) {
                    break;
                }
                if (mLastTouchX == x && mLastTouchY == y) {
                    break;
                }
                mLastTouchX = x;
                mLastTouchY = y;
                mDragging = mListener.onDragStart(v, this);
                return mDragging;
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                mDragging = false;
                break;
        }
        return false;
    }
public boolean onTouch ( View v , MotionEvent event ) { final int x = ( int ) event . getX ( ) ; final int y = ( int ) event . getY ( ) ; switch ( event . getAction ( ) ) { case MotionEvent . ACTION_DOWN : mLastTouchX = x ; mLastTouchY = y ; break ; case MotionEvent . ACTION_MOVE : if ( ! MotionEventCompat . isFromSource ( event , InputDeviceCompat . SOURCE_MOUSE ) || ( event . getButtonState ( ) & MotionEvent . BUTTON_PRIMARY ) == 0 ) { break ; } if ( mDragging ) { break ; } if ( mLastTouchX == x && mLastTouchY == y ) { break ; } mLastTouchX = x ; mLastTouchY = y ; mDragging = mListener . onDragStart ( v , this ) ; return mDragging ; case MotionEvent . ACTION_UP : case MotionEvent . ACTION_CANCEL : mDragging = false ; break ; } return false ; }
Handle a touch event.
Handle a touch event .
// Ignore ACTION_MOVE events once the drag operation is in progress. // Do not call the listener unless the pointer position has actually changed.