List of usage examples for android.support.v4.view MotionEventCompat ACTION_POINTER_UP
int ACTION_POINTER_UP
To view the source code for android.support.v4.view MotionEventCompat ACTION_POINTER_UP.
Click Source Link
From source file:com.juyujuyu.SwipeLoadLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { ensureTarget();// w w w . j a v a 2 s. co m final int action = MotionEventCompat.getActionMasked(ev); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; } if (!isEnabled() || mReturningToStart || mRefreshing || mNestedScrollInProgress) { // Fail fast if we're not in a state where a swipe is possible return false; } switch (action) { case MotionEvent.ACTION_DOWN: setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true); mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mIsBeingDragged = false; final float initialDownY = getMotionEventY(ev, mActivePointerId); if (initialDownY == -1) { return false; } mInitialDownY = initialDownY; break; case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER) { Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id."); return false; } final float y = getMotionEventY(ev, mActivePointerId); if (y == -1) { return false; } float difY = y - mInitialDownY; if (Math.abs(difY) > mTouchSlop) { if (difY > 0) { if (pullFromTop) pullDirection = PULL_DIRECTION_DOWN; else return false; } else { if (pullFromBottom) pullDirection = PULL_DIRECTION_UP; else return false; } if (pullDirection == PULL_DIRECTION_UP && canChildScrollDown() || pullDirection == PULL_DIRECTION_DOWN && canChildScrollUp()) { return false; } if (!mIsBeingDragged) { mInitialMotionY = mInitialDownY + mTouchSlop; mIsBeingDragged = true; mProgress.setAlpha(STARTING_PROGRESS_ALPHA); } } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mIsBeingDragged = false; mActivePointerId = INVALID_POINTER; break; } return mIsBeingDragged; }
From source file:cn.org.eshow.framwork.view.slidingmenu.CustomViewAbove.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (!mEnabled) return false; final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; if (DEBUG)/*from w w w.j ava 2 s . c om*/ if (action == MotionEvent.ACTION_DOWN) Log.v(TAG, "Received ACTION_DOWN"); if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP || (action != MotionEvent.ACTION_DOWN && mIsUnableToDrag)) { endDrag(); return false; } switch (action) { case MotionEvent.ACTION_MOVE: determineDrag(ev); break; case MotionEvent.ACTION_DOWN: int index = MotionEventCompat.getActionIndex(ev); mActivePointerId = MotionEventCompat.getPointerId(ev, index); if (mActivePointerId == INVALID_POINTER) break; mLastMotionX = mInitialMotionX = MotionEventCompat.getX(ev, index); mLastMotionY = MotionEventCompat.getY(ev, index); if (thisTouchAllowed(ev)) { mIsBeingDragged = false; mIsUnableToDrag = false; if (isMenuOpen() && mViewBehind.menuTouchInQuickReturn(mContent, mCurItem, ev.getX() + mScrollX)) { mQuickReturn = true; } } else { mIsUnableToDrag = true; } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; } if (!mIsBeingDragged) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(ev); } return mIsBeingDragged || mQuickReturn; }
From source file:com.rodrigo.flickr.view.wedget.SwipeRefreshLayoutBottom.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { ensureTarget();/*from ww w . j a v a 2s. c om*/ final int action = MotionEventCompat.getActionMasked(ev); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; } //if (!isEnabled() || mReturningToStart || canChildScrollUp() || mRefreshing) { if (!isEnabled() || mReturningToStart || canChildScrollDown() || mRefreshing) { // Fail fast if we're not in a state where a swipe is possible return false; } switch (action) { case MotionEvent.ACTION_DOWN: setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true); mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mIsBeingDragged = false; final float initialMotionY = getMotionEventY(ev, mActivePointerId); if (initialMotionY == -1) { return false; } mInitialMotionY = initialMotionY; case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER) { Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id."); return false; } final float y = getMotionEventY(ev, mActivePointerId); if (y == -1) { return false; } //final float yDiff = y - mInitialMotionY; final float yDiff = mInitialMotionY - y; if (yDiff > mTouchSlop && !mIsBeingDragged) { mIsBeingDragged = true; mProgress.setAlpha(STARTING_PROGRESS_ALPHA); } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mIsBeingDragged = false; mActivePointerId = INVALID_POINTER; break; } return mIsBeingDragged; }
From source file:com.example.parking.refresh.RefreshLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { ensureTarget();// w w w.j a va2 s. co m final int action = MotionEventCompat.getActionMasked(ev); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; } switch (mDirection) { case BOTTOM: if (!isEnabled() || mReturningToStart || (!mBothDirection && canChildScrollDown()) || mRefreshing) { // Fail fast if we're not in a state where a swipe is possible return false; } break; case TOP: default: if (!isEnabled() || mReturningToStart || (!mBothDirection && canChildScrollUp()) || mRefreshing) { // Fail fast if we're not in a state where a swipe is possible return false; } break; } switch (action) { case MotionEvent.ACTION_DOWN: setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true); mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mIsBeingDragged = false; final float initialMotionY = getMotionEventY(ev, mActivePointerId); if (initialMotionY == -1) { return false; } mInitialMotionY = initialMotionY; case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER) { return false; } final float y = getMotionEventY(ev, mActivePointerId); if (y == -1) { return false; } if (mBothDirection) { if (y > mInitialMotionY) { setRawDirection(SwipeRefreshLayoutDirection.TOP); } else if (y < mInitialMotionY) { setRawDirection(SwipeRefreshLayoutDirection.BOTTOM); } if ((mDirection == SwipeRefreshLayoutDirection.BOTTOM && canChildScrollDown()) || (mDirection == SwipeRefreshLayoutDirection.TOP && canChildScrollUp())) { return false; } } float yDiff; switch (mDirection) { case BOTTOM: yDiff = mInitialMotionY - y; break; case TOP: default: yDiff = y - mInitialMotionY; break; } if (yDiff > mTouchSlop && !mIsBeingDragged) { mIsBeingDragged = true; mProgress.setAlpha(STARTING_PROGRESS_ALPHA); } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mIsBeingDragged = false; mActivePointerId = INVALID_POINTER; break; } return mIsBeingDragged; }
From source file:com.cheng.animationstudy.customview.googleimitatecode.SwipyRefreshLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { ensureTarget();//from ww w . jav a 2 s. co m final int action = MotionEventCompat.getActionMasked(ev); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; } switch (mDirection) { case BOTTOM: if (!isEnabled() || mReturningToStart || (!mBothDirection && canChildScrollDown()) || mRefreshing) { // Fail fast if we're not in a state where a swipe is possible return false; } break; case TOP: default: if (!isEnabled() || mReturningToStart || (!mBothDirection && canChildScrollUp()) || mRefreshing) { // Fail fast if we're not in a state where a swipe is possible return false; } break; } switch (action) { case MotionEvent.ACTION_DOWN: setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true); mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mIsBeingDragged = false; final float initialMotionY = getMotionEventY(ev, mActivePointerId); if (initialMotionY == -1) { return false; } mInitialMotionY = initialMotionY; case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER) { return false; } final float y = getMotionEventY(ev, mActivePointerId); if (y == -1) { return false; } if (mBothDirection) { if (y > mInitialMotionY) { setRawDirection(SwipyRefreshLayoutDirection.TOP); } else if (y < mInitialMotionY) { setRawDirection(SwipyRefreshLayoutDirection.BOTTOM); } if ((mDirection == SwipyRefreshLayoutDirection.BOTTOM && canChildScrollDown()) || (mDirection == SwipyRefreshLayoutDirection.TOP && canChildScrollUp())) { return false; } } float yDiff; switch (mDirection) { case BOTTOM: yDiff = mInitialMotionY - y; break; case TOP: default: yDiff = y - mInitialMotionY; break; } if (yDiff > mTouchSlop && !mIsBeingDragged) { mIsBeingDragged = true; mProgress.setAlpha(STARTING_PROGRESS_ALPHA); } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mIsBeingDragged = false; mActivePointerId = INVALID_POINTER; break; } return mIsBeingDragged; }
From source file:com.hp.hoopeasy.widget.swipeRefresh.SwipeRefreshLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { ensureTarget();//w w w.j av a 2 s . com final int action = MotionEventCompat.getActionMasked(ev); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; } switch (mDirection) { case BOTTOM: if (!isEnabled() || mReturningToStart || (!mBothDirection && canChildScrollDown()) || mRefreshing) { // Fail fast if we're not in a state where a swipe is possible return false; } break; case TOP: default: if (!isEnabled() || mReturningToStart || (!mBothDirection && canChildScrollUp()) || mRefreshing) { // Fail fast if we're not in a state where a swipe is possible return false; } break; } switch (action) { case MotionEvent.ACTION_DOWN: setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true); mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mIsBeingDragged = false; final float initialDownY = getMotionEventY(ev, mActivePointerId); if (initialDownY == -1) { return false; } mInitialDownY = initialDownY; case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER) { return false; } final float y = getMotionEventY(ev, mActivePointerId); if (y == -1) { return false; } if (mBothDirection) { if (y > mInitialDownY) { setRawDirection(SwipeRefreshLayoutDirection.TOP); } else if (y < mInitialDownY) { setRawDirection(SwipeRefreshLayoutDirection.BOTTOM); } if ((mDirection == SwipeRefreshLayoutDirection.BOTTOM && canChildScrollDown()) || (mDirection == SwipeRefreshLayoutDirection.TOP && canChildScrollUp())) { mInitialDownY = y; return false; } } float yDiff; switch (mDirection) { case BOTTOM: yDiff = mInitialDownY - y; break; case TOP: default: yDiff = y - mInitialDownY; break; } if (yDiff > mTouchSlop && !mIsBeingDragged) { switch (mDirection) { case BOTTOM: mInitialMotionY = mInitialDownY - mTouchSlop; break; case TOP: default: mInitialMotionY = mInitialDownY + mTouchSlop; break; } mIsBeingDragged = true; mProgress.setAlpha(STARTING_PROGRESS_ALPHA); } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mIsBeingDragged = false; mActivePointerId = INVALID_POINTER; break; } return mIsBeingDragged; }
From source file:com.mucfc.refreshview.refresh.MySwipeRefreshLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { ensureTarget();// w ww . j ava 2s .c o m final int action = MotionEventCompat.getActionMasked(ev); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; } switch (mDirection) { case BOTTOM: if (!isEnabled() || mReturningToStart || (!mBothDirection && canChildScrollDown()) || mRefreshing) { // Fail fast if we're not in a state where a swipe is possible return false; } break; case TOP: default: if (!isEnabled() || mReturningToStart || (!mBothDirection && canChildScrollUp()) || mRefreshing) { // Fail fast if we're not in a state where a swipe is possible return false; } break; } switch (action) { case MotionEvent.ACTION_DOWN: setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true); mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mIsBeingDragged = false; final float initialDownY = getMotionEventY(ev, mActivePointerId); if (initialDownY == -1) { return false; } mInitialDownY = initialDownY; case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER) { return false; } final float y = getMotionEventY(ev, mActivePointerId); if (y == -1) { return false; } if (mBothDirection) { if (y > mInitialDownY) { setRawDirection(MySwipeRefreshLayoutDirection.TOP); } else if (y < mInitialDownY) { setRawDirection(MySwipeRefreshLayoutDirection.BOTTOM); } if ((mDirection == MySwipeRefreshLayoutDirection.BOTTOM && canChildScrollDown()) || (mDirection == MySwipeRefreshLayoutDirection.TOP && canChildScrollUp())) { mInitialDownY = y; return false; } } float yDiff = 0; switch (mDirection) { case BOTTOM: yDiff = mInitialDownY - y; break; case TOP: yDiff = y - mInitialDownY; break; case NONE: break; default: yDiff = y - mInitialDownY; break; } if (yDiff > mTouchSlop && !mIsBeingDragged) { switch (mDirection) { case BOTTOM: mInitialMotionY = mInitialDownY - mTouchSlop; break; case TOP: default: mInitialMotionY = mInitialDownY + mTouchSlop; break; } mIsBeingDragged = true; mProgress.setAlpha(STARTING_PROGRESS_ALPHA); } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mIsBeingDragged = false; mActivePointerId = INVALID_POINTER; break; } return mIsBeingDragged; }
From source file:com.melolchik.bullshitbingo.ui.views.swipe.BottomSwipeRefreshLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { ensureTarget();/*from w w w. j a va 2s . co m*/ final int action = MotionEventCompat.getActionMasked(ev); int pointerIndex; if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; } //log("onInterceptTouchEvent mNestedScrollInProgress = " + mNestedScrollInProgress); // log("canChildScrollDown() = " + canChildScrollDown()); if (!isEnabled() || mReturningToStart || canChildScrollDown() || mRefreshing || mNestedScrollInProgress) { // Fail fast if we're not in a state where a swipe is possible //log("onInterceptTouchEvent false action = " + action); return false; } //log("onInterceptTouchEvent cant scroll down action = " + action); switch (action) { case MotionEvent.ACTION_DOWN: setTargetOffsetTopAndBottom(0/*mOriginalOffsetTop + mCircleView.getTop()*/, true); mActivePointerId = ev.getPointerId(0); mIsBeingDragged = false; pointerIndex = ev.findPointerIndex(mActivePointerId); if (pointerIndex < 0) { return false; } mInitialDownY = ev.getY(pointerIndex); break; case MotionEvent.ACTION_MOVE: //log("ACTION_MOVE"); if (mActivePointerId == INVALID_POINTER) { log("ACTION_MOVE Got ACTION_MOVE event but don't have an active pointer id."); return false; } pointerIndex = ev.findPointerIndex(mActivePointerId); if (pointerIndex < 0) { log("ACTION_MOVE pointerIndex < 0"); return false; } final float y = ev.getY(pointerIndex); startDragging(y); break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mIsBeingDragged = false; mActivePointerId = INVALID_POINTER; break; } return mIsBeingDragged; }
From source file:com.king.view.superswiperefreshlayout.SuperSwipeRefreshLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { ensureTarget();/*from w w w . j av a 2s . com*/ final int action = MotionEventCompat.getActionMasked(ev); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; } switch (mDirection) { case BOTTOM: if (!isEnabled() || mReturningToStart || (!mBothDirection && canChildScrollDown()) || mRefreshing) { // Fail fast if we're not in a state where a swipe is possible return false; } break; case TOP: default: if (!isEnabled() || mReturningToStart || (!mBothDirection && canChildScrollUp()) || mRefreshing) { // Fail fast if we're not in a state where a swipe is possible return false; } break; } switch (action) { case MotionEvent.ACTION_DOWN: setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true); mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mIsBeingDragged = false; final float initialMotionY = getMotionEventY(ev, mActivePointerId); if (initialMotionY == -1) { return false; } mInitialMotionY = initialMotionY; case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER) { return false; } final float y = getMotionEventY(ev, mActivePointerId); if (y == -1) { return false; } if (mBothDirection) { if (y > mInitialMotionY) { setRawDirection(Direction.TOP); } else if (y < mInitialMotionY) { setRawDirection(Direction.BOTTOM); } if ((mDirection == Direction.BOTTOM && canChildScrollDown()) || (mDirection == Direction.TOP && canChildScrollUp())) { return false; } } float yDiff; switch (mDirection) { case BOTTOM: yDiff = mInitialMotionY - y; break; case TOP: default: yDiff = y - mInitialMotionY; break; } if (yDiff > mTouchSlop && !mIsBeingDragged) { mIsBeingDragged = true; mProgress.setAlpha(STARTING_PROGRESS_ALPHA); } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mIsBeingDragged = false; mActivePointerId = INVALID_POINTER; break; } return mIsBeingDragged; }
From source file:com.tuniu.widget.SwipeRefreshLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { ensureTarget();/* w w w . j a v a 2 s.co m*/ final int action = MotionEventCompat.getActionMasked(ev); Log.e("onInterceptTouchEvent", "canChildScrollUp======" + canChildScrollUp()); Log.e("onInterceptTouchEvent", "canChildScrollDown======" + canChildScrollDown()); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; } if (canChildScrollUp() && canChildScrollDown()) { return false; } if (!isEnabled() || mReturningToStart || mRefreshing || mNestedScrollInProgress) { // Fail fast if we're not in a state where a swipe is possible return false; } switch (action) { case MotionEvent.ACTION_DOWN: setTargetOffsetTopAndBottom(mOriginalOffsetTop - mCircleView.getTop(), true); mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mIsBeingDragged = false; final float initialDownY = getMotionEventY(ev, mActivePointerId); if (initialDownY == -1) { return false; } mInitialDownY = initialDownY; break; case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER) { Log.e(LOG_TAG, "Got ACTION_MOVE event but don't have an active pointer id."); return false; } final float y = getMotionEventY(ev, mActivePointerId); if (y == -1) { return false; } final float yDiff = y - mInitialDownY; Log.e("onInterceptTouchEvent", "yDiff==========" + yDiff); boolean draggin = ((!canChildScrollUp()) && yDiff > mTouchSlop) || ((!canChildScrollDown()) && yDiff < -mTouchSlop); if (draggin && !mIsBeingDragged) { mInitialMotionY = mInitialDownY + mTouchSlop; mIsBeingDragged = true; mProgress.setAlpha(STARTING_PROGRESS_ALPHA); } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mIsBeingDragged = false; mActivePointerId = INVALID_POINTER; break; } return mIsBeingDragged; }