List of usage examples for android.support.v4.view MotionEventCompat getActionMasked
public static int getActionMasked(MotionEvent event)
From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = MotionEventCompat.getActionMasked(ev); // "|" used deliberately here; both methods should be invoked. final boolean interceptForDrag = mTopDragger.shouldInterceptTouchEvent(ev) | mBottomDragger.shouldInterceptTouchEvent(ev); boolean interceptForTap = false; switch (action) { case MotionEvent.ACTION_DOWN: { final float x = ev.getX(); final float y = ev.getY(); mInitialMotionX = x;//from w w w .j ava 2s. c om mInitialMotionY = y; if (mScrimOpacity > 0 && isContentView(mTopDragger.findTopChildUnder((int) x, (int) y))) { interceptForTap = true; } mDisallowInterceptRequested = false; mChildrenCanceledTouch = false; break; } case MotionEvent.ACTION_MOVE: { // If we cross the touch slop, don't perform the delayed peek for an edge touch. if (mTopDragger.checkTouchSlop(ViewDragHelper.DIRECTION_ALL)) { mTopCallback.removeCallbacks(); mBottomCallback.removeCallbacks(); } break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: { closeDrawers(true); mDisallowInterceptRequested = false; mChildrenCanceledTouch = false; } } return interceptForDrag || interceptForTap || hasPeekingDrawer() || mChildrenCanceledTouch; }
From source file:com.fishstix.dosboxfree.DBGLSurfaceView.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @Override/*from www. ja va 2s. co m*/ public boolean onGenericMotionEvent(MotionEvent event) { if (event.getEventTime() + EVENT_THRESHOLD_DECAY < SystemClock.uptimeMillis()) { //Log.i("DosBoxTurbo","eventtime: "+event.getEventTime() + " systemtime: "+SystemClock.uptimeMillis()); return true; // get rid of old events } final int pointerIndex = MotionEventCompat.getActionIndex(event); final int pointerId = MotionEventCompat.getPointerId(event, pointerIndex); if ((MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_MOVE) && ((mWrap.getSource(event) & TouchEventWrapper.SOURCE_CLASS_MASK) == TouchEventWrapper.SOURCE_CLASS_JOYSTICK)) { if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) && (mAnalogStickPref < 3)) { // use new 3.1 API to handle joystick movements int historySize = event.getHistorySize(); for (int i = 0; i < historySize; i++) { processJoystickInput(event, i); } processJoystickInput(event, -1); return true; } else { // use older 2.2+ API to handle joystick movements if (mInputMode == INPUT_MODE_REAL_JOYSTICK) { x[pointerId] = mWrap.getX(event, pointerId); y[pointerId] = mWrap.getY(event, pointerId); DosBoxControl.nativeJoystick((int) ((x[pointerId] * 256f) + mJoyCenterX), (int) ((y[pointerId] * 256f) + mJoyCenterY), ACTION_MOVE, -1); return true; } } } else if ((MotionEventCompat.getActionMasked(event) == MotionEventCompat.ACTION_HOVER_MOVE) && ((mWrap.getSource(event) & TouchEventWrapper.SOURCE_CLASS_MASK) == TouchEventWrapper.SOURCE_CLASS_POINTER)) { if (mInputMode == INPUT_MODE_REAL_MOUSE) { x_last[pointerId] = x[pointerId]; y_last[pointerId] = y[pointerId]; x[pointerId] = mWrap.getX(event, pointerId); y[pointerId] = mWrap.getY(event, pointerId); if (mAbsolute) { DosBoxControl.nativeMouseWarp(x[pointerId], y[pointerId], mRenderer.x, mRenderer.y, mRenderer.width, mRenderer.height); } else { DosBoxControl.nativeMouse((int) (x[pointerId] * mMouseSensitivityX), (int) (y[pointerId] * mMouseSensitivityY), (int) (x_last[pointerId] * mMouseSensitivityX), (int) (y_last[pointerId] * mMouseSensitivityY), 2, -1); } int buttonState = mWrap.getButtonState(event); if (((buttonState & TouchEventWrapper.BUTTON_SECONDARY) != 0) && !mSPenButton) { // Handle Samsung SPen Button (RMB) - DOWN DosBoxControl.nativeMouse(0, 0, 0, 0, ACTION_DOWN, BTN_B); mSPenButton = true; } else if (((buttonState & TouchEventWrapper.BUTTON_SECONDARY) == 0) && mSPenButton) { // Handle Samsung SPen Button (RMB) - UP DosBoxControl.nativeMouse(0, 0, 0, 0, ACTION_UP, BTN_B); mSPenButton = false; } if (mDebug) Log.d("DosBoxTurbo", "onGenericMotionEvent() INPUT_MODE_REAL_MOUSE x: " + x[pointerId] + " y: " + y[pointerId] + " | xL: " + x_last[pointerId] + " yL: " + y_last[pointerId]); try { if (!mInputLowLatency) Thread.sleep(95); else Thread.sleep(65); } catch (InterruptedException e) { } return true; } } else if (MotionEventCompat.getActionMasked(event) == MotionEventCompat.ACTION_HOVER_EXIT) { if (mInputMode == INPUT_MODE_REAL_MOUSE) { // hover exit int buttonState = mWrap.getButtonState(event); if (((buttonState & TouchEventWrapper.BUTTON_SECONDARY) == 0) && mSPenButton) { // Handle Samsung SPen Button (RMB) - UP DosBoxControl.nativeMouse(0, 0, 0, 0, ACTION_UP, BTN_B); mSPenButton = false; return true; } } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) { return super.onGenericMotionEvent(event); } else { return false; } }
From source file:com.king.view.superslidingpanelayout.SuperSlidingPaneLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = MotionEventCompat.getActionMasked(ev); // Preserve the open state based on the last view that was touched. if (!mCanSlide && action == MotionEvent.ACTION_DOWN && getChildCount() > 1) { // After the first things will be slideable. final View secondChild = getChildAt(1); if (secondChild != null) { mPreservedOpenState = !mDragHelper.isViewUnder(secondChild, (int) ev.getX(), (int) ev.getY()); }/*from w ww .ja v a 2 s. c om*/ } if (!mCanSlide || (mIsUnableToDrag && action != MotionEvent.ACTION_DOWN)) { mDragHelper.cancel(); return super.onInterceptTouchEvent(ev); } if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { mDragHelper.cancel(); return false; } boolean interceptTap = false; switch (action) { case MotionEvent.ACTION_DOWN: { mIsUnableToDrag = false; final float x = ev.getX(); final float y = ev.getY(); mInitialMotionX = x; mInitialMotionY = y; if (mDragHelper.isViewUnder(mSlideableView, (int) x, (int) y) && isDimmed(mSlideableView)) { interceptTap = true; } break; } case MotionEvent.ACTION_MOVE: { final float x = ev.getX(); final float y = ev.getY(); // The user should always be able to "close" the pane, so we only check // for child scrollability if the pane is currently closed. if (mIsCompatSliding && mInitialMotionX > mEdgeSlop && !isOpen() && canScroll(this, false, Math.round(x - mInitialMotionX), Math.round(x), Math.round(y))) { // How do we set super.mIsUnableToDrag = true? // send the parent a cancel event MotionEvent cancelEvent = MotionEvent.obtain(ev); cancelEvent.setAction(MotionEvent.ACTION_CANCEL); return super.onInterceptTouchEvent(cancelEvent); } final float adx = Math.abs(x - mInitialMotionX); final float ady = Math.abs(y - mInitialMotionY); final int slop = mDragHelper.getTouchSlop(); if (adx > slop && ady > adx) { mDragHelper.cancel(); mIsUnableToDrag = true; return false; } } } final boolean interceptForDrag = mDragHelper.shouldInterceptTouchEvent(ev); return interceptForDrag || interceptTap; }
From source file:com.harry.refresh.SwipyRefreshLayout.java
@Override public boolean onTouchEvent(MotionEvent ev) { try {//w w w .j av a2 s.c o m final int action = MotionEventCompat.getActionMasked(ev); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; } switch (mDirection) { case BOTTOM: if (!isEnabled() || mReturningToStart || 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 || 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: mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mIsBeingDragged = false; break; case MotionEvent.ACTION_MOVE: { final int pointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); if (pointerIndex < 0) { return false; } final float y = MotionEventCompat.getY(ev, pointerIndex); float overscrollTop; switch (mDirection) { case BOTTOM: overscrollTop = (mInitialMotionY - y) * DRAG_RATE; break; case TOP: default: overscrollTop = (y - mInitialMotionY) * DRAG_RATE; break; } if (mIsBeingDragged) { mProgress.showArrow(true); float originalDragPercent = overscrollTop / mTotalDragDistance; if (originalDragPercent < 0) { return false; } float dragPercent = Math.min(1f, Math.abs(originalDragPercent)); float adjustedPercent = (float) Math.max(dragPercent - .4, 0) * 5 / 3; float extraOS = Math.abs(overscrollTop) - mTotalDragDistance; float slingshotDist = mUsingCustomStart ? mSpinnerFinalOffset - mOriginalOffsetTop : mSpinnerFinalOffset; float tensionSlingshotPercent = Math.max(0, Math.min(extraOS, slingshotDist * 2) / slingshotDist); float tensionPercent = (float) ((tensionSlingshotPercent / 4) - Math.pow( (tensionSlingshotPercent / 4), 2)) * 2f; float extraMove = (slingshotDist) * tensionPercent * 2; // int targetY = mOriginalOffsetTop + (int) ((slingshotDist * dragPercent) + extraMove); int targetY; if (mDirection == SwipeRefreshLayoutDirection.TOP) { targetY = mOriginalOffsetTop + (int) ((slingshotDist * dragPercent) + extraMove); } else { targetY = mOriginalOffsetTop - (int) ((slingshotDist * dragPercent) + extraMove); } // where 1.0f is a full circle if (mCircleView.getVisibility() != View.VISIBLE) { mCircleView.setVisibility(View.VISIBLE); } if (!mScale) { ViewCompat.setScaleX(mCircleView, 1f); ViewCompat.setScaleY(mCircleView, 1f); } if (overscrollTop < mTotalDragDistance) { if (mScale) { setAnimationProgress(overscrollTop / mTotalDragDistance); } if (mProgress.getAlpha() > STARTING_PROGRESS_ALPHA && !isAnimationRunning(mAlphaStartAnimation)) { // Animate the alpha startProgressAlphaStartAnimation(); } float strokeStart = (float) (adjustedPercent * .8f); mProgress.setStartEndTrim(0f, Math.min(MAX_PROGRESS_ANGLE, strokeStart)); mProgress.setArrowScale(Math.min(1f, adjustedPercent)); } else { if (mProgress.getAlpha() < MAX_ALPHA && !isAnimationRunning(mAlphaMaxAnimation)) { // Animate the alpha startProgressAlphaMaxAnimation(); } } float rotation = (-0.25f + .4f * adjustedPercent + tensionPercent * 2) * .5f; mProgress.setProgressRotation(rotation); setTargetOffsetTopAndBottom(targetY - mCurrentTargetOffsetTop, true /* requires update */); } break; } case MotionEventCompat.ACTION_POINTER_DOWN: { final int index = MotionEventCompat.getActionIndex(ev); mActivePointerId = MotionEventCompat.getPointerId(ev, index); break; } case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: { if (mActivePointerId == INVALID_POINTER) { if (action == MotionEvent.ACTION_UP) { } return false; } final int pointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); final float y = MotionEventCompat.getY(ev, pointerIndex); float overscrollTop; switch (mDirection) { case BOTTOM: overscrollTop = (mInitialMotionY - y) * DRAG_RATE; break; case TOP: default: overscrollTop = (y - mInitialMotionY) * DRAG_RATE; break; } mIsBeingDragged = false; if (overscrollTop > mTotalDragDistance) { setRefreshing(true, true /* notify */); } else { // cancel refresh mRefreshing = false; mProgress.setStartEndTrim(0f, 0f); AnimationListener listener = null; if (!mScale) { listener = new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (!mScale) { startScaleDownAnimation(null); } } @Override public void onAnimationRepeat(Animation animation) { } }; } animateOffsetToStartPosition(mCurrentTargetOffsetTop, listener); mProgress.showArrow(false); } mActivePointerId = INVALID_POINTER; return false; } } } catch (Exception e) { Log.e(TAG, "An exception occured during SwipyRefreshLayout onTouchEvent " + e.toString()); } return true; }
From source file:com.mde.potdroid.helpers.ptr.SwipyRefreshLayout.java
@Override public boolean onTouchEvent(MotionEvent ev) { try {/*from w w w . ja v a2 s . c o m*/ final int action = MotionEventCompat.getActionMasked(ev); if (mReturningToStart && action == MotionEvent.ACTION_DOWN) { mReturningToStart = false; } switch (mDirection) { case BOTTOM: if (!isEnabled() || mReturningToStart || 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 || 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: mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mIsBeingDragged = false; break; case MotionEvent.ACTION_MOVE: { final int pointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); if (pointerIndex < 0) { return false; } final float y = MotionEventCompat.getY(ev, pointerIndex); float overscrollTop; switch (mDirection) { case BOTTOM: overscrollTop = (mInitialMotionY - y) * DRAG_RATE; break; case TOP: default: overscrollTop = (y - mInitialMotionY) * DRAG_RATE; break; } if (mIsBeingDragged) { mProgress.showArrow(true); float originalDragPercent = overscrollTop / mTotalDragDistance; if (originalDragPercent < 0) { return false; } float dragPercent = Math.min(1f, Math.abs(originalDragPercent)); float adjustedPercent = (float) Math.max(dragPercent - .4, 0) * 5 / 3; float extraOS = Math.abs(overscrollTop) - mTotalDragDistance; float slingshotDist = mUsingCustomStart ? mSpinnerFinalOffset - mOriginalOffsetTop : mSpinnerFinalOffset; float tensionSlingshotPercent = Math.max(0, Math.min(extraOS, slingshotDist * 2) / slingshotDist); float tensionPercent = (float) ((tensionSlingshotPercent / 4) - Math.pow((tensionSlingshotPercent / 4), 2)) * 2f; float extraMove = (slingshotDist) * tensionPercent * 2; int targetY = mOriginalOffsetTop + (int) ((slingshotDist * dragPercent) + extraMove); /*int targetY; if (mDirection == SwipyRefreshLayoutDirection.TOP) { targetY = mOriginalOffsetTop + (int) ((slingshotDist * dragPercent) + extraMove); } else { targetY = mOriginalOffsetTop - (int) ((slingshotDist * dragPercent) + extraMove); }*/ // where 1.0f is a full circle if (mCircleView.getVisibility() != View.VISIBLE) { mCircleView.setVisibility(View.VISIBLE); } if (!mScale) { ViewCompat.setScaleX(mCircleView, 1f); ViewCompat.setScaleY(mCircleView, 1f); } if (overscrollTop < mTotalDragDistance) { if (mScale) { setAnimationProgress(overscrollTop / mTotalDragDistance); } if (mProgress.getAlpha() > STARTING_PROGRESS_ALPHA && !isAnimationRunning(mAlphaStartAnimation)) { // Animate the alpha startProgressAlphaStartAnimation(); } float strokeStart = (float) (adjustedPercent * .8f); mProgress.setStartEndTrim(0f, Math.min(MAX_PROGRESS_ANGLE, strokeStart)); mProgress.setArrowScale(Math.min(1f, adjustedPercent)); } else { if (mProgress.getAlpha() < MAX_ALPHA && !isAnimationRunning(mAlphaMaxAnimation)) { // Animate the alpha startProgressAlphaMaxAnimation(); } } float rotation = (-0.25f + .4f * adjustedPercent + tensionPercent * 2) * .5f; mProgress.setProgressRotation(rotation); setTargetOffsetTopAndBottom(targetY - mCurrentTargetOffsetTop, true /* requires update */); } break; } case MotionEventCompat.ACTION_POINTER_DOWN: { final int index = MotionEventCompat.getActionIndex(ev); mActivePointerId = MotionEventCompat.getPointerId(ev, index); break; } case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: { if (mActivePointerId == INVALID_POINTER) { if (action == MotionEvent.ACTION_UP) { } return false; } final int pointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); final float y = MotionEventCompat.getY(ev, pointerIndex); float overscrollTop; switch (mDirection) { case BOTTOM: overscrollTop = (mInitialMotionY - y) * DRAG_RATE; break; case TOP: default: overscrollTop = (y - mInitialMotionY) * DRAG_RATE; break; } mIsBeingDragged = false; if (overscrollTop > mTotalDragDistance) { setRefreshing(true, true /* notify */); } else { // cancel refresh mRefreshing = false; mProgress.setStartEndTrim(0f, 0f); AnimationListener listener = null; if (!mScale) { listener = new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (!mScale) { startScaleDownAnimation(null); } } @Override public void onAnimationRepeat(Animation animation) { } }; } animateOffsetToStartPosition(mCurrentTargetOffsetTop, listener); mProgress.showArrow(false); } mActivePointerId = INVALID_POINTER; return false; } } } catch (Exception e) { Log.e(TAG, "An exception occured during SwipyRefreshLayout onTouchEvent " + e.toString()); } return true; }
From source file:com.daiv.android.twitter.manipulations.widgets.NotificationDrawerLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = MotionEventCompat.getActionMasked(ev); // "|" used deliberately here; both methods should be invoked. try {//from www.ja v a 2 s . c o m final boolean interceptForDrag = isDrawerOpen(Gravity.RIGHT) ? mRightDragger.shouldInterceptTouchEvent(ev) : mLeftDragger.shouldInterceptTouchEvent(ev) | mRightDragger.shouldInterceptTouchEvent(ev); boolean interceptForTap = false; switch (action) { case MotionEvent.ACTION_DOWN: { final float x = ev.getX(); final float y = ev.getY(); mInitialMotionX = x; mInitialMotionY = y; if (mScrimOpacity > 0 && isContentView(mLeftDragger.findTopChildUnder((int) x, (int) y))) { interceptForTap = true; } mDisallowInterceptRequested = false; mChildrenCanceledTouch = false; break; } case MotionEvent.ACTION_MOVE: { // If we cross the touch slop, don't perform the delayed peek for an edge touch. if (mLeftDragger.checkTouchSlop(ViewDragHelper.DIRECTION_ALL)) { mLeftCallback.removeCallbacks(); mRightCallback.removeCallbacks(); } break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: { closeDrawers(true); mDisallowInterceptRequested = false; mChildrenCanceledTouch = false; } } return interceptForDrag || interceptForTap || hasPeekingDrawer() || mChildrenCanceledTouch; } catch (Exception e) { return false; } }
From source file:com.lansun.qmyo.view.DrawerLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { switch (ev.getAction()) { case MotionEvent.ACTION_UP: setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); break;// www . j av a2s . c om } final int action = MotionEventCompat.getActionMasked(ev); final boolean interceptForDrag = mLeftDragger.shouldInterceptTouchEvent(ev) | mRightDragger.shouldInterceptTouchEvent(ev); boolean interceptForTap = false; isOpen = false; if (findOpenDrawer() != null) { isOpen = true; } if (isOpen && xDistance == 0 && yDistance == 0) { isAllow = false; } switch (action) { case MotionEvent.ACTION_DOWN: { xDistance = yDistance = 0f; xLast = ev.getX(); yLast = ev.getY(); final float x = ev.getX(); final float y = ev.getY(); mInitialMotionX = x; mInitialMotionY = y; // System.out.println(mScrimOpacity + "|" + isContentView(mLeftDragger.findTopChildUnder((int) x, (int) y))); // if (mScrimOpacity > 0 && isContentView(mLeftDragger.findTopChildUnder((int) x, (int) y))) { // interceptForTap = true; // } mChildrenCanceledTouch = false; break; } case MotionEvent.ACTION_MOVE: { final float curX = ev.getX(); final float curY = ev.getY(); xDistance += Math.abs(curX - xLast); yDistance += Math.abs(curY - yLast); xLast = curX; yLast = curY; // if (isOpen && (xDistance > (yDistance + 20))) { // System.out.println("XY"); // isAllow = true; // } if ((xDistance > (yDistance + 20))) { isAllow = true; } // If we cross the touch slop, don't perform the delayed peek for an edge touch. if (mLeftDragger.checkTouchSlop(ViewDragHelper.DIRECTION_ALL)) { mLeftCallback.removeCallbacks(); mRightCallback.removeCallbacks(); } break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: { closeDrawers(true); mChildrenCanceledTouch = false; } } // System.out.println(mLockModeLeft + "|" + interceptForDrag + "|" + isAllow); // System.out.println((interceptForDrag && isAllow) + "|" + interceptForTap + "|" + hasPeekingDrawer() + "|" + mChildrenCanceledTouch); return (interceptForDrag && isAllow) || interceptForTap || hasPeekingDrawer() || mChildrenCanceledTouch; }
From source file:com.abewy.android.apps.klyph.widget.KlyphDrawerLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = MotionEventCompat.getActionMasked(ev); // "|" used deliberately here; both methods should be invoked. final boolean interceptForDrag = mLeftDragger.shouldInterceptTouchEvent(ev) | mRightDragger.shouldInterceptTouchEvent(ev); boolean interceptForTap = false; switch (action) { case MotionEvent.ACTION_DOWN: { final float x = ev.getX(); final float y = ev.getY(); mInitialMotionX = x;//from www. java2 s. c om mInitialMotionY = y; if (mScrimOpacity > 0 && isContentView(mLeftDragger.findTopChildUnder((int) x, (int) y))) { interceptForTap = true; } mDisallowInterceptRequested = false; mChildrenCanceledTouch = false; break; } case MotionEvent.ACTION_MOVE: { // If we cross the touch slop, don't perform the delayed peek for an edge touch. if (mLeftDragger.checkTouchSlop(ViewDragHelper.DIRECTION_ALL)) { mLeftCallback.removeCallbacks(); mRightCallback.removeCallbacks(); } break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: { closeDrawers(true); mDisallowInterceptRequested = false; mChildrenCanceledTouch = false; } } return interceptForDrag || interceptForTap || hasPeekingDrawer() || mChildrenCanceledTouch; }
From source file:com.popofibo.weatherpop.custom.DrawerLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = MotionEventCompat.getActionMasked(ev); // "|" used deliberately here; both methods should be invoked. final boolean interceptForDrag = mLeftDragger.shouldInterceptTouchEvent(ev) | mRightDragger.shouldInterceptTouchEvent(ev); boolean interceptForTap = false; switch (action) { case MotionEvent.ACTION_DOWN: { final float x = ev.getX(); final float y = ev.getY(); mInitialMotionX = x;//from www. j a v a 2s . com mInitialMotionY = y; if (mScrimOpacity > 0 && isContentView(mLeftDragger.findTopChildUnder((int) x, (int) y))) { interceptForTap = true; } mChildrenCanceledTouch = false; break; } case MotionEvent.ACTION_MOVE: { // If we cross the touch slop, don't perform the delayed peek for an // edge touch. if (mLeftDragger.checkTouchSlop(ViewDragHelper.DIRECTION_ALL)) { mLeftCallback.removeCallbacks(); mRightCallback.removeCallbacks(); } break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: { closeDrawers(true); mChildrenCanceledTouch = false; } } return interceptForDrag || interceptForTap || hasPeekingDrawer() || mChildrenCanceledTouch; }
From source file:com.callba.phone.widget.refreshlayout.RefreshLayout.java
private boolean headerInterceptTouchEvent(MotionEvent ev) { final int action = MotionEventCompat.getActionMasked(ev); switch (action) { case MotionEvent.ACTION_DOWN: setHeaderTargetOffsetTopAndBottom(mHeaderOriginalOffsetTop - mCircleView.getTop(), true); mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mIsHeaderBeingDragged = false;//from w ww. j a v a 2 s. c o m 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; if (yDiff > mTouchSlop && !mIsHeaderBeingDragged) { mInitialMotionY = mInitialDownY + mTouchSlop; mIsHeaderBeingDragged = true; mProgress.setAlpha(STARTING_PROGRESS_ALPHA); } break; case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mIsHeaderBeingDragged = false; mActivePointerId = INVALID_POINTER; break; } return mIsHeaderBeingDragged; }