Example usage for android.view MotionEvent getAction

List of usage examples for android.view MotionEvent getAction

Introduction

In this page you can find the example usage for android.view MotionEvent getAction.

Prototype

public final int getAction() 

Source Link

Document

Return the kind of action being performed.

Usage

From source file:com.android.mail.browse.ConversationItemView.java

private boolean onTouchEventNoSwipe(MotionEvent event) {
    Utils.traceBeginSection("on touch event no swipe");
    boolean handled = false;

    int x = (int) event.getX();
    int y = (int) event.getY();
    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
        if (isTouchInContactPhoto(x, y) || isTouchInInfoIcon(x, y) || isTouchInStar(x, y)) {
            mDownEvent = true;/*from   w  ww  .  ja va  2s  .  co  m*/
            handled = true;
        }
        break;

    case MotionEvent.ACTION_CANCEL:
        mDownEvent = false;
        break;

    case MotionEvent.ACTION_UP:
        if (mDownEvent) {
            if (isTouchInContactPhoto(x, y)) {
                // Touch on the check mark
                toggleCheckedState();
            } else if (isTouchInInfoIcon(x, y)) {
                if (mConversationItemAreaClickListener != null) {
                    mConversationItemAreaClickListener.onInfoIconClicked();
                }
            } else if (isTouchInStar(x, y)) {
                // Touch on the star
                if (mConversationItemAreaClickListener == null) {
                    toggleStar();
                } else {
                    mConversationItemAreaClickListener.onStarClicked();
                }
            }
            handled = true;
        }
        break;
    }

    if (!handled) {
        handled = super.onTouchEvent(event);
    }

    Utils.traceEndSection();
    return handled;
}

From source file:com.apptentive.android.sdk.view.ApptentiveNestedScrollView.java

public boolean onGenericMotionEvent(MotionEvent event) {
    if ((MotionEventCompat.getSource(event) & InputDeviceCompat.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
        case MotionEventCompat.ACTION_SCROLL: {
            if (!mIsBeingDragged) {
                final float vscroll = MotionEventCompat.getAxisValue(event, MotionEventCompat.AXIS_VSCROLL);
                if (vscroll != 0) {
                    final int delta = (int) (vscroll * getVerticalScrollFactorCompat());
                    final int range = getScrollRange();
                    int oldScrollY = getScrollY();
                    int newScrollY = oldScrollY - delta;
                    if (newScrollY < 0) {
                        newScrollY = 0;//from  w w w . ja  v  a 2s  .c om
                    } else if (newScrollY > range) {
                        newScrollY = range;
                    }
                    if (newScrollY != oldScrollY) {
                        super.scrollTo(getScrollX(), newScrollY);
                        return true;
                    }
                }
            }
        }
        }
    }
    return false;
}

From source file:com.android.mail.browse.ConversationItemView.java

/**
 * ConversationItemView is given the first chance to handle touch events.
 *///w  w  w  .j ava 2  s.  c  o m
@Override
public boolean onTouchEvent(MotionEvent event) {
    Utils.traceBeginSection("on touch event");
    int x = (int) event.getX();
    int y = (int) event.getY();
    if (!mSwipeEnabled) {
        Utils.traceEndSection();
        return onTouchEventNoSwipe(event);
    }
    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
        if (isTouchInContactPhoto(x, y) || isTouchInInfoIcon(x, y) || isTouchInStar(x, y)) {
            mDownEvent = true;
            Utils.traceEndSection();
            return true;
        }
        break;
    case MotionEvent.ACTION_UP:
        if (mDownEvent) {
            if (isTouchInContactPhoto(x, y)) {
                // Touch on the check mark
                Utils.traceEndSection();
                mDownEvent = false;
                toggleCheckedState();
                Utils.traceEndSection();
                return true;
            } else if (isTouchInInfoIcon(x, y)) {
                // Touch on the info icon
                mDownEvent = false;
                if (mConversationItemAreaClickListener != null) {
                    mConversationItemAreaClickListener.onInfoIconClicked();
                }
                Utils.traceEndSection();
                return true;
            } else if (isTouchInStar(x, y)) {
                // Touch on the star
                mDownEvent = false;
                if (mConversationItemAreaClickListener == null) {
                    toggleStar();
                } else {
                    mConversationItemAreaClickListener.onStarClicked();
                }
                Utils.traceEndSection();
                return true;
            }
        }
        break;
    }
    // Let View try to handle it as well.
    boolean handled = super.onTouchEvent(event);
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        Utils.traceEndSection();
        return true;
    }
    Utils.traceEndSection();
    return handled;
}

From source file:com.owncloud.android.authentication.AuthenticatorActivity.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType)
            && mHostUrlInput.hasFocus() && event.getAction() == MotionEvent.ACTION_DOWN) {
        checkOcServer();/*from w  w  w . j av  a2s  . c o m*/
    }
    return super.onTouchEvent(event);
}

From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java

@Override
public boolean onTouchEvent(MotionEvent ev) {
    mLeftDragger.processTouchEvent(ev);/*from   w ww. j  a v  a  2 s.  com*/
    mRightDragger.processTouchEvent(ev);

    final int action = ev.getAction();
    boolean wantTouchEvents = true;

    switch (action & MotionEventCompat.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN: {
        final float x = ev.getX();
        final float y = ev.getY();
        mInitialMotionX = x;
        mInitialMotionY = y;
        mDisallowInterceptRequested = false;
        mChildrenCanceledTouch = false;
        break;
    }

    case MotionEvent.ACTION_UP: {
        final float x = ev.getX();
        final float y = ev.getY();
        boolean peekingOnly = true;
        final View touchedView = mLeftDragger.findTopChildUnder((int) x, (int) y);
        if (touchedView != null && isContentView(touchedView)) {
            final float dx = x - mInitialMotionX;
            final float dy = y - mInitialMotionY;
            final int slop = mLeftDragger.getTouchSlop();
            if (dx * dx + dy * dy < slop * slop) {
                // Taps close a dimmed open drawer but only if it isn't locked open.
                final View openDrawer = findOpenDrawer();
                if (openDrawer != null) {
                    peekingOnly = getDrawerLockMode(openDrawer) == LOCK_MODE_LOCKED_OPEN;
                }
            }
        }
        closeDrawers(peekingOnly);
        mDisallowInterceptRequested = false;
        break;
    }

    case MotionEvent.ACTION_CANCEL: {
        closeDrawers(true);
        mDisallowInterceptRequested = false;
        mChildrenCanceledTouch = false;
        break;
    }
    }

    return wantTouchEvents;
}

From source file:com.android.launcher2.PagedView.java

@Override
public boolean onGenericMotionEvent(MotionEvent event) {
    if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) {
        switch (event.getAction()) {
        case MotionEvent.ACTION_SCROLL: {
            // Handle mouse (or ext. device) by shifting the page depending on the scroll
            final float vscroll;
            final float hscroll;
            if ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0) {
                vscroll = 0;//from   w ww . j  a v a2  s . c o m
                hscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
            } else {
                vscroll = -event.getAxisValue(MotionEvent.AXIS_VSCROLL);
                hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
            }
            if (hscroll != 0 || vscroll != 0) {
                if (hscroll > 0 || vscroll > 0) {
                    scrollRight();
                } else {
                    scrollLeft();
                }
                return true;
            }
        }
        }
    }
    return super.onGenericMotionEvent(event);
}

From source file:com.chrynan.guitarchords.view.GuitarChordView.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (isInChartBounds(event)) {
        boolean isMarkerInChord = false;
        int fret = NO_FRET, string = -1;
        fret = getSelectedFret(event);/* w w w  .  j  a  v a2  s .com*/
        string = getSelectedString(event);
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            detector.onTouchEvent(event);
        }
        if (event.getAction() == MotionEvent.ACTION_UP && touchEventMarker != null) {
            if (fret == touchEventMarker.getFret()) {
                int startString = 1, endString = 1;
                startString = (touchEventMarker.getStartString() < string) ? touchEventMarker.getStartString()
                        : string;
                endString = (touchEventMarker.getEndString() >= string) ? touchEventMarker.getEndString()
                        : string;
                ChordMarker marker = new ChordMarker(startString, endString, fret,
                        touchEventMarker.getFinger());
                isMarkerInChord = chord.contains(marker);
                alertOnChordSelected(event, marker, isMarkerInChord);
                if (editable) {
                    return true;
                }
                return super.onTouchEvent(event);
            }
        }
        if (editable) {
            return true;
        }
    } else if (isInFretNumberBounds(event)) {
        alertOnFretNumberSelected(event, getSelectedFret(event));
    } else if (isInStringMarkerBounds(event)) {
        alertOnStringSelectedListener(event, getSelectedString(event));
    }
    return super.onTouchEvent(event);
}

From source file:com.gizwits.smartlight.activity.MainListActivity.java

/**
 * Inits the events.//from w ww  . j  a  v  a 2 s  . co m
 */
private void initEvents() {
    ivMenu.setOnClickListener(this);
    tvTitle.setOnClickListener(this);
    llFooter.setOnClickListener(this);
    tvEditSceneName.setOnClickListener(this);
    iftttButton.setOnClickListener(this);
    iftttButton.setClickable(false);
    // etGroup.setOnClickListener(this);
    //For lightness
    moveStep1 = (float) (((float) screenWidth / (float) 254) * 0.8);
    //For Hue
    moveStep2 = (float) (((float) screenWidth / (float) 65279) * 0.8);
    //For saturation
    moveStep3 = (float) (((float) screenWidth / (float) 254) * 0.8);

    lvDevice.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!mAdapter.getItem(position).isOnline())
                return;

            if (mAdapter.getChoosedPos() == position) {
                mView.toggle();
                return;
            }

            mAdapter.setChoosedPos(position);
            mXpgWifiDevice = bindlist.get(position);
            loginDevice(mXpgWifiDevice);
        }
    });
    sbLightness.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                sbLightness.getParent().requestDisallowInterceptTouchEvent(true);
                break;
            case MotionEvent.ACTION_CANCEL:
                sbLightness.getParent().requestDisallowInterceptTouchEvent(false);
                break;
            }
            return false;
        }
    });
    sbLightness.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
            mLightness = seekBar.getProgress();
            text_light.layout((int) (mLightness * moveStep1), 20, screenWidth, 80);
            text_light.setText(Integer.toString(mLightness));
            if (!selectGroup.equals("") && selectGroup != null) {
                mCenter.cLightnessGroup(selectGroup, seekBar.getProgress());

            } else {
                mCenter.cLightness(selectSubDevice, seekBar.getProgress());
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
        }
    });

    sbSaturation.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                sbSaturation.getParent().requestDisallowInterceptTouchEvent(true);
                break;
            case MotionEvent.ACTION_CANCEL:
                sbSaturation.getParent().requestDisallowInterceptTouchEvent(false);
                break;
            }
            return false;
        }
    });
    sbSaturation.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
            mSaturation = seekBar.getProgress();
            text_saturation.layout((int) (mSaturation * moveStep3), 20, screenWidth, 80);
            text_saturation.setText(Integer.toString(mSaturation));

            if (!selectGroup.equals("") && selectGroup != null) {
                mCenter.cSaturationGroup(selectGroup, seekBar.getProgress());
            } else {
                mCenter.cSaturation(selectSubDevice, seekBar.getProgress());
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // TODO Auto-generated method stub
        }
    });

    sbColor.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                sbColor.getParent().requestDisallowInterceptTouchEvent(true);
                break;
            case MotionEvent.ACTION_CANCEL:
                sbColor.getParent().requestDisallowInterceptTouchEvent(false);
                break;
            }
            return false;
        }
    });
    sbColor.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub
            mHue = seekBar.getProgress();
            text_hue.layout((int) (mHue * moveStep2), 20, screenWidth, 80);
            text_hue.setText(Integer.toString(mHue));
            if (!selectGroup.equals("") && selectGroup != null) {
                mCenter.cColorGroup(selectGroup, seekBar.getProgress());
            } else {
                mCenter.cColor(selectSubDevice, seekBar.getProgress());
            }
        }

        @Override
        public void onProgressChanged(SeekBar arg0, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar bar) {

        }
    });
    alpha_bg.setOnClickListener(this);
    ivEdit.setOnClickListener(this);
    sclContent.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            if (position == list.size() - 1) {
                Intent intent = new Intent(MainListActivity.this, EditGroupActivity.class);
                intent.putStringArrayListExtra("ledList", GroupDevice.getAllName(ledList));
                intent.putExtra("did", "" + centralControlDevice.getDid());
                startActivity(intent);
            }
        }
    });

    sclContent.setOnRefreshListener(new OnRefreshListener() {

        @Override
        public void onRefresh(RefreshableListView listView) {
            // TODO Auto-generated method stub
            Log.i(TAG, "slip down to refresh.........");
            mCenter.cGetGroups(setmanager.getUid(), setmanager.getToken(), Configs.PRODUCT_KEY_Sub);//?
            mCenter.cGetSubDevicesList(centralControlDevice);

            final Timer timer = new Timer();
            timer.schedule(new TimerTask() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    runOnUiThread(new Runnable() {
                        public void run() {
                            sclContent.completeRefreshing();
                        }
                    });
                    timer.cancel();
                }
            }, 2000);
        }
    });
    btnSwitch.setOnClickListener(this);
    addSceneButton.setOnClickListener(this);

    sceneListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> a, View v, int position, long id) {
            Object o = sceneListView.getItemAtPosition(position);
            scene obj_itemDetails = (scene) o;
            Log.i(TAG, "click now is " + obj_itemDetails.getName() + " " + obj_itemDetails.getValue());
        }
    });
}

From source file:bw.com.yunifangstore.view.OrderLazyViewPager.java

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {

    /*//from  www.ja v  a  2 s . co m
     * This method JUST determines whether we want to intercept the motion.
     * If we return true, onMotionEvent will be called and we do the actual
     * scrolling there.
     */

    final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;

    // Always take care of the touch gesture being complete.
    if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
        // Release the drag.
        if (DEBUG)
            Log.v(TAG, "Intercept done!");
        mIsBeingDragged = false;
        mIsUnableToDrag = false;
        mActivePointerId = INVALID_POINTER;
        return false;
    }

    // Nothing more to do here if we have decided whether or not we
    // are dragging.
    if (action != MotionEvent.ACTION_DOWN) {
        if (mIsBeingDragged) {
            if (DEBUG)
                Log.v(TAG, "Intercept returning true!");
            return true;
        }
        if (mIsUnableToDrag) {
            if (DEBUG)
                Log.v(TAG, "Intercept returning false!");
            return false;
        }
    }

    switch (action) {
    case MotionEvent.ACTION_MOVE: {
        /*
         * mIsBeingDragged == false, otherwise the shortcut would have caught it. Check
         * whether the user has moved far enough from his original down touch.
         *//*
                    
            *//*
               * Locally do absolute value. mLastMotionY is set to the y value
               * of the down event.
               */
        final int activePointerId = mActivePointerId;
        if (activePointerId == INVALID_POINTER) {
            // If we don't have a valid id, the touch down wasn't on content.
            break;
        }

        final int pointerIndex = MotionEventCompat.findPointerIndex(ev, activePointerId);
        final float x = MotionEventCompat.getX(ev, pointerIndex);
        final float dx = x - mLastMotionX;
        final float xDiff = Math.abs(dx);
        final float y = MotionEventCompat.getY(ev, pointerIndex);
        final float yDiff = Math.abs(y - mLastMotionY);
        final int scrollX = getScrollX();
        final boolean atEdge = (dx > 0 && scrollX == 0)
                || (dx < 0 && mAdapter != null && scrollX >= (mAdapter.getCount() - 1) * getWidth() - 1);
        if (DEBUG)
            Log.v(TAG, "Moved x to " + x + "," + y + " diff=" + xDiff + "," + yDiff);

        if (canScroll(this, false, (int) dx, (int) x, (int) y)) {
            // Nested view has scrollable area under this point. Let it be handled there.
            mInitialMotionX = mLastMotionX = x;
            mLastMotionY = y;
            return false;
        }
        if (xDiff > mTouchSlop && xDiff > yDiff) {
            if (DEBUG)
                Log.v(TAG, "Starting drag!");
            mIsBeingDragged = true;
            setScrollState(SCROLL_STATE_DRAGGING);
            mLastMotionX = x;
            setScrollingCacheEnabled(true);
        } else {
            if (yDiff > mTouchSlop) {
                // The finger has moved enough in the vertical
                // direction to be counted as a drag...  abort
                // any attempt to drag horizontally, to work correctly
                // with children that have scrolling containers.
                if (DEBUG)
                    Log.v(TAG, "Starting unable to drag!");
                mIsUnableToDrag = true;
            }
        }
        break;
    }

    case MotionEvent.ACTION_DOWN: {
        /*
         * Remember location of down touch.
         * ACTION_DOWN always refers to pointer index 0.
         */
        mLastMotionX = mInitialMotionX = ev.getX();
        mLastMotionY = ev.getY();
        mActivePointerId = MotionEventCompat.getPointerId(ev, 0);

        if (mScrollState == SCROLL_STATE_SETTLING) {
            // Let the user 'catch' the pager as it animates.
            mIsBeingDragged = true;
            mIsUnableToDrag = false;
            setScrollState(SCROLL_STATE_DRAGGING);
        } else {
            completeScroll();
            mIsBeingDragged = false;
            mIsUnableToDrag = false;
        }

        if (DEBUG)
            Log.v(TAG, "Down at " + mLastMotionX + "," + mLastMotionY + " mIsBeingDragged=" + mIsBeingDragged
                    + "mIsUnableToDrag=" + mIsUnableToDrag);
        break;
    }

    case MotionEventCompat.ACTION_POINTER_UP:
        onSecondaryPointerUp(ev);
        break;
    }

    /** The only time we want to intercept motion events is if we are in the
    * drag mode.*/

    return mIsBeingDragged;

}

From source file:cn.d.fesa.wuf.ui.view.LazyViewPager.java

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    /*//from   w  w  w .  j  av  a 2  s.c o m
     * This method JUST determines whether we want to intercept the motion.
     * If we return true, onMotionEvent will be called and we do the actual
     * scrolling there.
     */

    final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;

    // Always take care of the touch gesture being complete.
    if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
        // Release the drag.
        if (DEBUG)
            Log.v(TAG, "Intercept done!");
        mIsBeingDragged = false;
        mIsUnableToDrag = false;
        mActivePointerId = INVALID_POINTER;
        return false;
    }

    // Nothing more to do here if we have decided whether or not we
    // are dragging.
    if (action != MotionEvent.ACTION_DOWN) {
        if (mIsBeingDragged) {
            if (DEBUG)
                Log.v(TAG, "Intercept returning true!");
            return true;
        }
        if (mIsUnableToDrag) {
            if (DEBUG)
                Log.v(TAG, "Intercept returning false!");
            return false;
        }
    }

    switch (action) {
    case MotionEvent.ACTION_MOVE: {
        /*
         * mIsBeingDragged == false, otherwise the shortcut would have caught it. Check
         * whether the user has moved far enough from his original down touch.
         */

        /*
        * Locally do absolute value. mLastMotionY is set to the y value
        * of the down event.
        */
        final int activePointerId = mActivePointerId;
        if (activePointerId == INVALID_POINTER) {
            // If we don't have a valid id, the touch down wasn't on content.
            break;
        }

        final int pointerIndex = MotionEventCompat.findPointerIndex(ev, activePointerId);
        final float x = MotionEventCompat.getX(ev, pointerIndex);
        final float dx = x - mLastMotionX;
        final float xDiff = Math.abs(dx);
        final float y = MotionEventCompat.getY(ev, pointerIndex);
        final float yDiff = Math.abs(y - mLastMotionY);
        final int scrollX = getScrollX();
        final boolean atEdge = (dx > 0 && scrollX == 0)
                || (dx < 0 && mAdapter != null && scrollX >= (mAdapter.getCount() - 1) * getWidth() - 1);
        if (DEBUG)
            Log.v(TAG, "Moved x to " + x + "," + y + " diff=" + xDiff + "," + yDiff);

        if (canScroll(this, false, (int) dx, (int) x, (int) y)) {
            // Nested view has scrollable area under this point. Let it be handled there.
            mInitialMotionX = mLastMotionX = x;
            mLastMotionY = y;
            return false;
        }
        if (xDiff > mTouchSlop && xDiff > yDiff) {
            if (DEBUG)
                Log.v(TAG, "Starting drag!");
            mIsBeingDragged = true;
            setScrollState(SCROLL_STATE_DRAGGING);
            mLastMotionX = x;
            setScrollingCacheEnabled(true);
        } else {
            if (yDiff > mTouchSlop) {
                // The finger has moved enough in the vertical
                // direction to be counted as a drag...  abort
                // any attempt to drag horizontally, to work correctly
                // with children that have scrolling containers.
                if (DEBUG)
                    Log.v(TAG, "Starting unable to drag!");
                mIsUnableToDrag = true;
            }
        }
        break;
    }

    case MotionEvent.ACTION_DOWN: {
        /*
         * Remember location of down touch.
         * ACTION_DOWN always refers to pointer index 0.
         */
        mLastMotionX = mInitialMotionX = ev.getX();
        mLastMotionY = ev.getY();
        mActivePointerId = MotionEventCompat.getPointerId(ev, 0);

        if (mScrollState == SCROLL_STATE_SETTLING) {
            // Let the user 'catch' the pager as it animates.
            mIsBeingDragged = true;
            mIsUnableToDrag = false;
            setScrollState(SCROLL_STATE_DRAGGING);
        } else {
            completeScroll();
            mIsBeingDragged = false;
            mIsUnableToDrag = false;
        }

        if (DEBUG)
            Log.v(TAG, "Down at " + mLastMotionX + "," + mLastMotionY + " mIsBeingDragged=" + mIsBeingDragged
                    + "mIsUnableToDrag=" + mIsUnableToDrag);
        break;
    }

    case MotionEventCompat.ACTION_POINTER_UP:
        onSecondaryPointerUp(ev);
        break;
    }

    /*
    * The only time we want to intercept motion events is if we are in the
    * drag mode.
    */
    return mIsBeingDragged;
}