Example usage for android.view MotionEvent ACTION_MOVE

List of usage examples for android.view MotionEvent ACTION_MOVE

Introduction

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

Prototype

int ACTION_MOVE

To view the source code for android.view MotionEvent ACTION_MOVE.

Click Source Link

Document

Constant for #getActionMasked : A change has happened during a press gesture (between #ACTION_DOWN and #ACTION_UP ).

Usage

From source file:com.andview.refreshview.swipe.SwipeMenuLayout.java

@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (mVelocityTracker == null)
        mVelocityTracker = VelocityTracker.obtain();
    mVelocityTracker.addMovement(ev);//w w  w  .  j  a v  a  2 s.  c o  m
    int dx;
    int dy;
    int action = ev.getAction();
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        mLastX = (int) ev.getX();
        mLastY = (int) ev.getY();
        break;
    case MotionEvent.ACTION_MOVE:
        if (!isSwipeEnable())
            break;
        int disX = (int) (mLastX - ev.getX());
        int disY = (int) (mLastY - ev.getY());
        if (!mDragging && Math.abs(disX) > mScaledTouchSlop && Math.abs(disX) > Math.abs(disY)) {
            mDragging = true;
        }
        if (mDragging) {
            if (mSwipeCurrentHorizontal == null || shouldResetSwipe) {
                if (disX < 0) {
                    if (mSwipeLeftHorizontal != null)
                        mSwipeCurrentHorizontal = mSwipeLeftHorizontal;
                    else
                        mSwipeCurrentHorizontal = mSwipeRightHorizontal;
                } else {
                    if (mSwipeRightHorizontal != null)
                        mSwipeCurrentHorizontal = mSwipeRightHorizontal;
                    else
                        mSwipeCurrentHorizontal = mSwipeLeftHorizontal;
                }
            }
            scrollBy(disX, 0);
            mLastX = (int) ev.getX();
            mLastY = (int) ev.getY();
            shouldResetSwipe = false;
        }
        break;
    case MotionEvent.ACTION_UP:
        dx = (int) (mDownX - ev.getX());
        dy = (int) (mDownY - ev.getY());
        mDragging = false;
        mVelocityTracker.computeCurrentVelocity(1000, mScaledMaximumFlingVelocity);
        int velocityX = (int) mVelocityTracker.getXVelocity();
        int velocity = Math.abs(velocityX);
        if (velocity > mScaledMinimumFlingVelocity) {
            if (mSwipeCurrentHorizontal != null) {
                int duration = getSwipeDuration(ev, velocity);
                if (mSwipeCurrentHorizontal instanceof SwipeRightHorizontal) {
                    if (velocityX < 0) {
                        smoothOpenMenu(duration);
                    } else {
                        smoothCloseMenu(duration);
                    }
                } else {
                    if (velocityX > 0) {
                        smoothOpenMenu(duration);
                    } else {
                        smoothCloseMenu(duration);
                    }
                }
                ViewCompat.postInvalidateOnAnimation(this);
            }
        } else {
            judgeOpenClose(dx, dy);
        }
        mVelocityTracker.clear();
        mVelocityTracker.recycle();
        mVelocityTracker = null;
        if (Math.abs(mDownX - ev.getX()) > mScaledTouchSlop || Math.abs(mDownY - ev.getY()) > mScaledTouchSlop
                || isMenuOpen()) {
            ev.setAction(MotionEvent.ACTION_CANCEL);
            super.onTouchEvent(ev);
            return true;
        }
        break;
    case MotionEvent.ACTION_CANCEL:
        mDragging = false;
        if (!mScroller.isFinished()) {
            mScroller.abortAnimation();
        } else {
            dx = (int) (mDownX - ev.getX());
            dy = (int) (mDownY - ev.getY());
            judgeOpenClose(dx, dy);
        }
        break;
    }
    return super.onTouchEvent(ev);
}

From source file:cn.ieclipse.af.view.ScrollLayout.java

@Override
public boolean onTouchEvent(MotionEvent event) {

    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }/* ww  w .  j ava  2s  . c o  m*/
    mVelocityTracker.addMovement(event);

    final int action = event.getAction();
    final float x = event.getX();
    final float y = event.getY();

    switch (action) {
    case MotionEvent.ACTION_DOWN:
        if (debug) {
            Log.v(TAG, "event down!");
        }
        if (!mScroller.isFinished()) {
            mScroller.abortAnimation();
        }
        mLastMotionX = x;
        break;

    case MotionEvent.ACTION_MOVE:
        int deltaX = (int) (mLastMotionX - x);
        mLastMotionX = x;

        scrollBy(deltaX, 0);
        break;

    case MotionEvent.ACTION_UP:
        if (debug) {
            Log.v(TAG, "event : up");
        }
        // if (mTouchState == TOUCH_STATE_SCROLLING) {
        final VelocityTracker velocityTracker = mVelocityTracker;
        velocityTracker.computeCurrentVelocity(1000);
        int velocityX = (int) velocityTracker.getXVelocity();
        if (debug) {
            Log.v(TAG, "velocityX:" + velocityX);
        }

        if (velocityX > mSnapVelocity) {
            if (mCurScreen > 0) {
                // Fling enough to move left
                if (debug) {
                    Log.v(TAG, "snap left");
                }
                snapToScreen(mCurScreen - 1);
            } else {
                // TODO
                disableWipe(false);
                snapToDestination();
            }
        } else if (velocityX < -mSnapVelocity) {
            if (mCurScreen < getChildCount() - 1) {
                // Fling enough to move right
                if (debug) {
                    Log.v(TAG, "snap right");
                }
                snapToScreen(mCurScreen + 1);
            } else {
                // TODO
                disableWipe(false);
                snapToDestination();
            }
        } else {
            snapToDestination();
        }

        if (mVelocityTracker != null) {
            mVelocityTracker.recycle();
            mVelocityTracker = null;
        }
        // }
        mTouchState = TOUCH_STATE_REST;
        break;
    case MotionEvent.ACTION_CANCEL:
        mTouchState = TOUCH_STATE_REST;
        break;
    }

    return true;
}

From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java

@Override
public void onCreate(Bundle saveInstanceState) {
    super.onCreate(saveInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    Bundle b = getIntent().getExtras();/*  w  ww  .  j  a  v  a2 s .co  m*/

    SharedPreferences prefs = getSharedPreferences("settings", MODE_PRIVATE);

    imageOptions = new DisplayImageOptions.Builder().cacheInMemory(false).cacheOnDisk(true)
            .bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.EXACTLY)
            .showImageOnLoading(R.drawable.connecting_anim).build();
    config = new ImageLoaderConfiguration.Builder(getApplicationContext()).diskCacheExtraOptions(480, 320, null)
            .defaultDisplayImageOptions(imageOptions).build();

    if (imageLoader == null)
        imageLoader = ImageLoader.getInstance();
    if (!imageLoader.isInited())
        imageLoader.init(config);

    setContentView(R.layout.link_dialog);

    imageFrame = (FrameLayout) findViewById(R.id.image_frame);
    iBottomPanel = (ImageView) findViewById(R.id.bottom_panel);

    lArtistLink = (RelativeLayout) findViewById(R.id.l_artist_link);

    bPopUpClose = (ImageView) findViewById(R.id.b_popup_close);
    bPopUpClose.setOnClickListener(this);

    tEchoNest = (TextView) findViewById(R.id.t_echo_nest);
    tAttribution = (TextView) findViewById(R.id.t_attribution);

    tArtistName = (TextView) findViewById(R.id.t_artist_name);
    tArtistName.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                //isMove = false;
                mTouchX = event.getRawX();
                mTouchY = event.getRawY();
                break;

            case MotionEvent.ACTION_UP:
                //Log.i("musicInfo", "ACTION_UP! TouchY:" + mTouchY + " UpY: " + event.getRawY() + " Move: " + (mTouchY - event.getRawY()));
                int RawY = (int) event.getRawY();
                int dY = (int) (mTouchY - event.getRawY());
                if (dY > 200) {
                    imageLoader.resume();
                    //Log.i("musicInfo", "mGridView TOP = " + mGridView.getTop() + " mGridView TransitionY =" + mGridView.getTranslationY());
                    while (mGridView.getTranslationY() > tArtistName.getHeight()) {
                        //Log.i("musicInfo", "Moving UP! mGridView: " + mGridView.getTranslationY() + " tArtistName: " + tArtistName.getTranslationY());
                        mGridView.setTranslationY(mGridView.getTranslationY() - 1);
                        tArtistName.setTranslationY(tArtistName.getTranslationY() - 1);

                    }
                } else if (dY > 5 && dY <= 200 || (dY <= 5 && tArtistName.getTranslationY() < 0)) {
                    while (tArtistName.getTranslationY() < 0) {
                        //Log.i("musicInfo", "Moving DOWN! mGridView: " + mGridView.getTranslationY() + " tArtistName: " + tArtistName.getTranslationY());
                        mGridView.setTranslationY(mGridView.getTranslationY() + 1);
                        tArtistName.setTranslationY(tArtistName.getTranslationY() + 1);
                    }
                    imageLoader.pause();
                }
                break;

            case MotionEvent.ACTION_MOVE:
                //isMove = true;

                //int top = tArtistName.getTop();
                //int bottom = tArtistName.getBottom();
                //int left = tArtistName.getLeft();
                //int right = tArtistName.getRight();

                int x = (int) (event.getRawX() - mTouchX);
                int y = (int) (event.getRawY() - mTouchY);

                final int num = 5;
                if (y > -num && y < num) {
                    //isMove = false;
                    break;
                } else if (y > 0) {

                } else {
                    imageFrame.bringChildToFront(mGridView);
                    tArtistName.setTranslationY((float) y);
                    mGridView.setTranslationY((float) (SGVtransition + y));

                    //Log.i("musicInfo", String.format("T: %d, B: %d", mGridView.getTop(), mGridView.getBottom()));

                }

                break;
            }
            return true;
        }
    });

    ArtistImage = (ImageView) findViewById(R.id.artist_image);

    lLinkList = (LinearLayout) findViewById(R.id.l_link_list);

    mGridView = (StaggeredGridView) findViewById(R.id.SG_view);

    SGVtransition = 900;

    mGridView.setTranslationY(SGVtransition);

    JSONObject artist_info = null;
    try {
        artist_info = new JSONObject(b.getString("artist_info"));
        Log.i("musicInfo", "LinkPopUp. OnCreate" + artist_info.toString());
        displayArtistInfo(artist_info);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    if (artist_info != null)
        jArtists.put(artist_info);
    if (prefs.getBoolean("SimilarOn", false)) {
        getSimilarArtistsInfo((String) tArtistName.getText());
        ArtistImage.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    //isMove = false;
                    mTouchX = event.getRawX();
                    mTouchY = event.getRawY();
                    break;

                case MotionEvent.ACTION_UP:
                    //Log.i("musicInfo", "ACTION_UP! TouchY:" + mTouchY + " UpY: " + event.getRawY() + " Move: " + (mTouchY - event.getRawY()));
                    int dX = (int) (mTouchX - event.getRawX());
                    if (dX > 5) {
                        if (jArtists.length() > 1) {
                            imageLoader.stop();
                            try {
                                if (artistNum == 0) {
                                    artistNum = jArtists.length() - 1;
                                } else {
                                    artistNum--;
                                }

                                displayArtistInfo(jArtists.getJSONObject(artistNum));
                                imageLoader.resume();

                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                        }

                    } else if (dX < -5) {
                        if (jArtists.length() > 1) {
                            imageLoader.stop();
                            try {
                                if (artistNum == jArtists.length() - 1) {
                                    artistNum = 0;
                                } else {
                                    artistNum++;
                                }
                                displayArtistInfo(jArtists.getJSONObject(artistNum));
                                imageLoader.resume();
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }

                        }

                    }

                    break;

                case MotionEvent.ACTION_MOVE:

                    break;
                }

                return true;
            }
        });
    }

    mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            //Log.d("musicInfo", "SGV onScrollStateChanged:" + scrollState);
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            //Log.d("musicInfo", "SGV onScroll firstVisibleItem:" + firstVisibleItem + " visibleItemCount:" + visibleItemCount + " totalItemCount:" + totalItemCount);
            // our handling
            if (!mHasRequestedMore) {
                int lastInScreen = firstVisibleItem + visibleItemCount;
                if (lastInScreen >= totalItemCount) {
                    //Log.d("musicInfo", "SGV onScroll lastInScreen - so load more");
                    mHasRequestedMore = true;
                    onLoadMoreItems();
                }
            }
        }

        private void onLoadMoreItems() {
            if (jVideoArray == null)
                return;
            final ArrayList<JSONObject> sampleData = generateImageData(jVideoArray);
            for (JSONObject data : sampleData) {
                mAdapter.add(data);
            }
            // stash all the data in our backing store
            mData.addAll(sampleData);
            // notify the adapter that we can update now
            mAdapter.notifyDataSetChanged();
            mHasRequestedMore = false;
        }
    });

    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(getApplicationContext(), "Open the Video...", Toast.LENGTH_SHORT).show();
            StaggeredViewAdapter.ViewHolder vh = (StaggeredViewAdapter.ViewHolder) view.getTag();

            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setData(Uri.parse((String) vh.url));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            //finish();

        }

    });

    //int[] lArtistLinkPosition = new int[2];
    //int[] tArtistNamePosition = new int[2];

    //lArtistLink.getLocationOnScreen(lArtistLinkPosition);
    //tArtistName.getLocationOnScreen(tArtistNamePosition);

    //Log.d("musicInfo", "SGV transition = " + SGVtransition);
}

From source file:com.android.gallery3d.v5.filtershow.category.CategoryView.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    boolean ret = super.onTouchEvent(event);
    FilterShowActivity activity = (FilterShowActivity) getContext();

    if (event.getActionMasked() == MotionEvent.ACTION_UP) {
        activity.startTouchAnimation(this, event.getX(), event.getY());
    }/*from w w w.  j  a v a 2  s. c o  m*/
    if (!canBeRemoved()) {
        return ret;
    }
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        mStartTouchY = event.getY();
        mStartTouchX = event.getX();
    }
    if (event.getActionMasked() == MotionEvent.ACTION_UP) {
        setTranslationX(0);
        setTranslationY(0);
    }
    if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
        float delta = event.getY() - mStartTouchY;
        if (getOrientation() == CategoryView.VERTICAL) {
            delta = event.getX() - mStartTouchX;
        }
        if (Math.abs(delta) > mDeleteSlope) {
            activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
        }
    }
    return true;
}

From source file:com.baoyz.dribble.widget.SwipeHoverLayout.java

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    int actionMasked = MotionEventCompat.getActionMasked(ev);
    boolean flag = false;
    switch (actionMasked) {
    case MotionEvent.ACTION_DOWN:
        mDownX = (int) ev.getX();
        mGestureDetector.onTouchEvent(ev);
        break;//from   w  w  w .j  a  va 2  s  .c o  m
    case MotionEvent.ACTION_MOVE:
        if (Math.abs(ev.getX() - mDownX) > mTouchSlop)
            flag = true;
        break;
    }
    return flag;
}

From source file:com.android.hiparker.lierda_light.view.viewpagerindicator.LinePageIndicator.java

public boolean onTouchEvent(android.view.MotionEvent ev) {
    if (super.onTouchEvent(ev)) {
        return true;
    }//www. java  2s  . com
    if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) {
        return false;
    }

    final int action = ev.getAction() & MotionEventCompat.ACTION_MASK;
    switch (action) {
    case MotionEvent.ACTION_DOWN:
        mActivePointerId = MotionEventCompat.getPointerId(ev, 0);
        mLastMotionX = ev.getX();
        break;

    case MotionEvent.ACTION_MOVE: {
        final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId);
        final float x = MotionEventCompat.getX(ev, activePointerIndex);
        final float deltaX = x - mLastMotionX;

        if (!mIsDragging) {
            if (Math.abs(deltaX) > mTouchSlop) {
                mIsDragging = true;
            }
        }

        if (mIsDragging) {
            mLastMotionX = x;
            if (mViewPager.isFakeDragging() || mViewPager.beginFakeDrag()) {
                mViewPager.fakeDragBy(deltaX);
            }
        }

        break;
    }

    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        if (!mIsDragging) {
            final int count = mViewPager.getAdapter().getCount();
            final int width = getWidth();
            final float halfWidth = width / 2f;
            final float sixthWidth = width / 6f;

            if ((mCurrentPage > 0) && (ev.getX() < halfWidth - sixthWidth)) {
                if (action != MotionEvent.ACTION_CANCEL) {
                    mViewPager.setCurrentItem(mCurrentPage - 1);
                }
                return true;
            } else if ((mCurrentPage < count - 1) && (ev.getX() > halfWidth + sixthWidth)) {
                if (action != MotionEvent.ACTION_CANCEL) {
                    mViewPager.setCurrentItem(mCurrentPage + 1);
                }
                return true;
            }

        }

        mIsDragging = false;
        mActivePointerId = INVALID_POINTER;
        if (mViewPager.isFakeDragging())
            mViewPager.endFakeDrag();
        break;

    case MotionEventCompat.ACTION_POINTER_DOWN: {
        final int index = MotionEventCompat.getActionIndex(ev);
        mLastMotionX = MotionEventCompat.getX(ev, index);
        mActivePointerId = MotionEventCompat.getPointerId(ev, index);
        break;
    }

    case MotionEventCompat.ACTION_POINTER_UP:
        final int pointerIndex = MotionEventCompat.getActionIndex(ev);
        final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
        if (pointerId == mActivePointerId) {
            final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
            mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
        }
        mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId));
        break;
    }

    return true;
}

From source file:com.android.messaging.ui.conversationlist.ConversationListSwipeHelper.java

@Override
public void onTouchEvent(final RecyclerView recyclerView, final MotionEvent event) {
    // We should only be here if we intercepted the touch due to swipe.
    Assert.isTrue(mIsSwiping);//  w  w w  .  ja  va 2  s  .c  o m

    // We are now tracking a swipe gesture.
    mVelocityTracker.addMovement(event);

    final int action = event.getActionMasked();
    switch (action) {
    case MotionEvent.ACTION_OUTSIDE:
    case MotionEvent.ACTION_MOVE:
        if (hasValidGestureSwipeTarget()) {
            mListItemView.setSwipeTranslationX(event.getX() - mInitialX);
        }
        break;
    case MotionEvent.ACTION_UP:
        if (hasValidGestureSwipeTarget()) {
            final float maxVelocity = mMaximumFlingVelocity;
            mVelocityTracker.computeCurrentVelocity(UNIT_SECONDS, maxVelocity);
            final float velocityX = getLastComputedXVelocity();

            final float translationX = mListItemView.getSwipeTranslationX();

            int swipeDirection = SWIPE_DIRECTION_NONE;
            if (translationX != 0) {
                swipeDirection = translationX > 0 ? SWIPE_DIRECTION_RIGHT : SWIPE_DIRECTION_LEFT;
            } else if (velocityX != 0) {
                swipeDirection = velocityX > 0 ? SWIPE_DIRECTION_RIGHT : SWIPE_DIRECTION_LEFT;
            }

            final boolean fastEnough = isTargetSwipedFastEnough();
            final boolean farEnough = isTargetSwipedFarEnough();

            final boolean shouldDismiss = (fastEnough || farEnough);

            if (shouldDismiss) {
                if (fastEnough) {
                    animateDismiss(mListItemView, velocityX);
                } else {
                    animateDismiss(mListItemView, swipeDirection);
                }
            } else {
                animateRestore(mListItemView, velocityX);
            }

            onSwipeGestureEnd(mListItemView, shouldDismiss ? swipeDirection : SWIPE_DIRECTION_NONE);
        } else {
            onGestureEnd();
        }
        break;
    case MotionEvent.ACTION_CANCEL:
        if (hasValidGestureSwipeTarget()) {
            animateRestore(mListItemView, 0f);
            onSwipeGestureEnd(mListItemView, SWIPE_DIRECTION_NONE);
        } else {
            onGestureEnd();
        }
        break;
    }
}

From source file:com.android2.calculator3.view.CalculatorPadView.java

@Override
public boolean onTouchEvent(MotionEvent event) {
    if (!mInterceptingTouchEvents) {
        onInterceptTouchEvent(event);/*from w w w  .j  av  a2 s  .com*/
        return true;
    }

    int action = MotionEventCompat.getActionMasked(event);

    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }
    mVelocityTracker.addMovement(event);

    switch (action) {
    case MotionEvent.ACTION_DOWN:
        // Handled in intercept
        break;
    case MotionEvent.ACTION_MOVE:
        handleMove(event);
        break;
    case MotionEvent.ACTION_UP:
        handleUp(event);
        break;
    }

    return true;
}

From source file:com.roger.lineselectionwebview.LSWebView.java

@SuppressWarnings("deprecation")
@Override// w  w w. j a  v a  2 s.c  o  m
public boolean onTouch(View v, MotionEvent event) {

    if (!isLineMode) {
        return false;
    }

    @SuppressWarnings("deprecation")
    float xPoint = getDensityIndependentValue(event.getX(), mContext)
            / getDensityIndependentValue(getScale(), mContext);
    float yPoint = getDensityIndependentValue(event.getY(), mContext)
            / getDensityIndependentValue(getScale(), mContext);

    if (event.getAction() == MotionEvent.ACTION_DOWN) {

        String startTouchUrl = String.format(Locale.US, "javascript:android.selection.startTouch(%f, %f);",
                xPoint, yPoint);

        mLastTouchX = xPoint;
        mLastTouchY = yPoint;
        loadUrl(startTouchUrl);

        // Tell the javascript to handle this if not in selection mode
        if (!isInSelectionMode()) {
            loadUrl("javascript:android.selection.longTouch();");
            mScrolling = true;
        }

        // Flag scrolling for first touch
        // mScrolling = !isInSelectionMode();

    } else if (event.getAction() == MotionEvent.ACTION_UP) {
        // Check for scrolling flag
        if (!mScrolling) {
            mScrolling = false;
            endSelectionMode();
            return false;
        }

        mScrolling = false;

        // Fixes 4.4 double selection
        return true;

    } else if (event.getAction() == MotionEvent.ACTION_MOVE) {

        mLastTouchX = xPoint;
        mLastTouchY = yPoint;

    }
    // If this is in selection mode, then nothing else should handle this
    // touch
    return false;
}

From source file:cn.bingoogolapple.refreshlayout.BGAStickyNavLayout.java

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    float currentTouchY = ev.getY();
    switch (ev.getAction()) {
    case MotionEvent.ACTION_DOWN:
        mLastDispatchY = currentTouchY;//from www. ja v a  2s .  c om
        break;
    case MotionEvent.ACTION_MOVE:
        float differentY = currentTouchY - mLastDispatchY;
        mLastDispatchY = currentTouchY;
        if (isContentViewToTop() && isHeaderViewCompleteInvisible()) {
            if (differentY >= 0 && !mIsInControl) {
                mIsInControl = true;

                return resetDispatchTouchEvent(ev);
            }

            if (differentY <= 0 && mIsInControl) {
                mIsInControl = false;

                return resetDispatchTouchEvent(ev);
            }
        }
        break;
    }
    return super.dispatchTouchEvent(ev);
}