Code example for MotionEvent

Methods: getActionobtain

0
    void startLongPressTimerIfNeeded(MotionEvent ev) {
        if (!canHandle(ev)) return;
 
        if (mCurrentDownEvent != null) mCurrentDownEvent.recycle();
 
        mCurrentDownEvent = MotionEvent.obtain(ev);
        mLongPressHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime()
                + TAP_TIMEOUT + LONGPRESS_TIMEOUT);
        mInLongPress = false;
    } 
 
    private boolean canHandle(MotionEvent ev) {
        return ev.getAction() == MotionEvent.ACTION_DOWN;
    } 
 
    // Cancel LONG_PRESS timers. 
    void cancelLongPressIfNeeded(MotionEvent ev) {
        if (!hasPendingMessage() || 
            mCurrentDownEvent == null || ev.getDownTime() != mCurrentDownEvent.getDownTime()) {
            return; 
        }