Java Code Examples for android.view.MotionEvent#INVALID_POINTER_ID
The following examples show how to use
android.view.MotionEvent#INVALID_POINTER_ID .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ForwardingListener.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public void onViewDetachedFromWindow(View v) { mForwarding = false; mActivePointerId = MotionEvent.INVALID_POINTER_ID; if (mDisallowIntercept != null) { mSrc.removeCallbacks(mDisallowIntercept); } }
Example 2
Source File: ForwardingListener.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
@Override public void onViewDetachedFromWindow(View v) { mForwarding = false; mActivePointerId = MotionEvent.INVALID_POINTER_ID; if (mDisallowIntercept != null) { mSrc.removeCallbacks(mDisallowIntercept); } }
Example 3
Source File: ResolverDrawerLayout.java From android-bottomsheet with ISC License | 5 votes |
private void resetTouch() { mActivePointerId = MotionEvent.INVALID_POINTER_ID; mIsDragging = false; mOpenOnClick = false; mInitialTouchX = mInitialTouchY = mLastTouchY = 0; mVelocityTracker.clear(); }
Example 4
Source File: MultiPointerGestureDetector.java From fresco with MIT License | 5 votes |
private void updatePointersOnTap(MotionEvent event) { mPointerCount = 0; for (int i = 0; i < MAX_POINTERS; i++) { int index = getPressedPointerIndex(event, i); if (index == -1) { mId[i] = MotionEvent.INVALID_POINTER_ID; } else { mId[i] = event.getPointerId(index); mCurrentX[i] = mStartX[i] = event.getX(index); mCurrentY[i] = mStartY[i] = event.getY(index); mPointerCount++; } } }
Example 5
Source File: MultiPointerGestureDetector.java From fresco with MIT License | 5 votes |
/** Resets the component to the initial state. */ public void reset() { mGestureInProgress = false; mPointerCount = 0; for (int i = 0; i < MAX_POINTERS; i++) { mId[i] = MotionEvent.INVALID_POINTER_ID; } }
Example 6
Source File: MultiPointerGestureDetector.java From ZoomableDraweeView-sample with Apache License 2.0 | 5 votes |
/** * Resets the component to the initial state. */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void reset() { mGestureInProgress = false; mCount = 0; for (int i = 0; i < MAX_POINTERS; i++) { mId[i] = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH ? -1 : MotionEvent.INVALID_POINTER_ID; } }
Example 7
Source File: MultiPointerGestureDetector.java From droidddle with Apache License 2.0 | 5 votes |
/** * Resets the component to the initial state. */ public void reset() { mGestureInProgress = false; mCount = 0; for (int i = 0; i < MAX_POINTERS; i++) { mId[i] = MotionEvent.INVALID_POINTER_ID; } }
Example 8
Source File: MultiPointerGestureDetector.java From FrescoUtils with Apache License 2.0 | 5 votes |
/** * Resets the component to the initial state. */ public void reset() { mGestureInProgress = false; mCount = 0; for (int i = 0; i < MAX_POINTERS; i++) { mId[i] = MotionEvent.INVALID_POINTER_ID; } }
Example 9
Source File: MultiPointerGestureDetector.java From materialup with Apache License 2.0 | 5 votes |
/** * Resets the component to the initial state. */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void reset() { mGestureInProgress = false; mCount = 0; for (int i = 0; i < MAX_POINTERS; i++) { mId[i] = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH ? -1 : MotionEvent.INVALID_POINTER_ID; } }
Example 10
Source File: GesturesListener.java From XposedNavigationBar with GNU General Public License v3.0 | 5 votes |
private int findIndex(int pointerId) { for (int i = 0; i < mDownPointers; i++) { if (mDownPointerId[i] == pointerId) { return i; } } if (mDownPointers == MAX_TRACKED_POINTERS || pointerId == MotionEvent.INVALID_POINTER_ID) { return UNTRACKED_POINTER; } mDownPointerId[mDownPointers++] = pointerId; return mDownPointers - 1; }
Example 11
Source File: MultiPointerGestureDetector.java From CommentGallery with Apache License 2.0 | 5 votes |
private void updatePointersOnTap(MotionEvent event) { mPointerCount = 0; for (int i = 0; i < MAX_POINTERS; i++) { int index = getPressedPointerIndex(event, i); if (index == -1) { mId[i] = MotionEvent.INVALID_POINTER_ID; } else { mId[i] = event.getPointerId(index); mCurrentX[i] = mStartX[i] = event.getX(index); mCurrentY[i] = mStartY[i] = event.getY(index); mPointerCount++; } } }
Example 12
Source File: MultiPointerGestureDetector.java From CommentGallery with Apache License 2.0 | 5 votes |
/** * Resets the component to the initial state. */ public void reset() { mGestureInProgress = false; mPointerCount = 0; for (int i = 0; i < MAX_POINTERS; i++) { mId[i] = MotionEvent.INVALID_POINTER_ID; } }
Example 13
Source File: MultiPointerGestureDetector.java From imsdk-android with MIT License | 5 votes |
/** * Resets the component to the initial state. */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void reset() { mGestureInProgress = false; mCount = 0; for (int i = 0; i < MAX_POINTERS; i++) { mId[i] = Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH ? -1 : MotionEvent.INVALID_POINTER_ID; } }
Example 14
Source File: SystemGesturesPointerEventListener.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private int findIndex(int pointerId) { for (int i = 0; i < mDownPointers; i++) { if (mDownPointerId[i] == pointerId) { return i; } } if (mDownPointers == MAX_TRACKED_POINTERS || pointerId == MotionEvent.INVALID_POINTER_ID) { return UNTRACKED_POINTER; } mDownPointerId[mDownPointers++] = pointerId; return mDownPointers - 1; }
Example 15
Source File: MovableTouchListener.java From Noyze with Apache License 2.0 | 4 votes |
@Override public boolean onTouch(View v, MotionEvent event) { if (null != mAnimator && mAnimator.isRunning()) return false; if (null == mPopupWindow) return false; switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: LayoutParams params = mPopupWindow.getWindowParams(); aPID = event.getPointerId(0); downX = (int) (params.x - event.getRawX()); downY = (int) (params.y - event.getRawY()); break; case MotionEvent.ACTION_UP: // Handle "snapping" to the right/ left edge of the screen. if (null != mAnchor) { final Rect mBounds = mPopupWindow.getBounds(); final int[] screen = mPopupWindow.getWindowDimensions(); switch (mAnchor) { case AXIS_Y: if (mBounds.left + (mBounds.width() / 2) > (screen[0] / 2)) { // Snap right. snap(screen[0] - mBounds.width(), PopupWindow.POSITION_UNCHANGED); } else { // Snap left. snap(0, PopupWindow.POSITION_UNCHANGED); } break; case AXIS_X: if (mBounds.top + (mBounds.height() / 2) > (screen[1] / 2)) { // Snap bottom. snap(PopupWindow.POSITION_UNCHANGED, screen[1] - mBounds.height()); } else { // Snap top. snap(PopupWindow.POSITION_UNCHANGED, 0); } break; case EDGES: if (mBounds.top + (mBounds.height() / 2) > (screen[1] / 2)) { // Snap bottom half. if (mBounds.left + (mBounds.width() / 2) > (screen[0] / 2)) // Snap bottom right. snap(screen[0] - mBounds.width(), screen[1] - mBounds.height()); else // Snap bottom left. snap(0, screen[1] - mBounds.height()); } else { // Snap top half. if (mBounds.left + (mBounds.width() / 2) > (screen[0] / 2)) // Snap top right. snap(screen[0] - mBounds.width(), 0); else // Snap top left. snap(0, 0); } break; } } break; case MotionEvent.ACTION_POINTER_UP: // Extract the index of the pointer that left the touch sensor final int pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; final int pointerId = event.getPointerId(pointerIndex); if (pointerId == aPID) { // This was our active pointer going up. Choose a new // active pointer and adjust accordingly. final int newPointerIndex = (pointerIndex == 0) ? 1 : 0; aPID = event.getPointerId(newPointerIndex); } case MotionEvent.ACTION_MOVE: // Find the index of the active pointer and fetch its position final int mPID = event.findPointerIndex(aPID); float xMove = event.getRawX(); float yMove = event.getRawY(); // From http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html final int dx = (int) (xMove + downX); final int dy = (int) (yMove + downY); mPopupWindow.position(((lockX) ? PopupWindow.POSITION_UNCHANGED : dx), ((lockY) ? PopupWindow.POSITION_UNCHANGED : dy)); break; case MotionEvent.ACTION_CANCEL: aPID = MotionEvent.INVALID_POINTER_ID; break; } return true; }
Example 16
Source File: BottomSheetBehavior.java From bottomsheetrecycler with Apache License 2.0 | 4 votes |
@Override public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) { if (!child.isShown()) { ignoreEvents = true; return false; } int action = event.getActionMasked(); // Record the velocity if (action == MotionEvent.ACTION_DOWN) { reset(); } if (velocityTracker == null) { velocityTracker = VelocityTracker.obtain(); } velocityTracker.addMovement(event); switch (action) { case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: touchingScrollingChild = false; activePointerId = MotionEvent.INVALID_POINTER_ID; // Reset the ignore flag if (ignoreEvents) { ignoreEvents = false; return false; } break; case MotionEvent.ACTION_DOWN: int initialX = (int) event.getX(); initialY = (int) event.getY(); // Only intercept nested scrolling events here if the view not being moved by the // ViewDragHelper. if (mNestedScrollingChildRefList != null) { for (View childView : mNestedScrollingChildRefList) { if (childView != null && parent.isPointInChildBounds(childView, initialX, initialY)) { activePointerId = event.getPointerId(event.getActionIndex()); touchingScrollingChild = true; } } } ignoreEvents = activePointerId == MotionEvent.INVALID_POINTER_ID && !parent.isPointInChildBounds(child, initialX, initialY); break; default: // fall out } if (!ignoreEvents && viewDragHelper != null && viewDragHelper.shouldInterceptTouchEvent(event)) { return true; } // We have to handle cases that the ViewDragHelper does not capture the bottom sheet because // it is not the top most view of its parent. This is not necessary when the touch event is // happening over the scrolling content as nested scrolling logic handles that case. //View scroll = nestedScrollingChildRef != null ? nestedScrollingChildRef.get() : null; return action == MotionEvent.ACTION_MOVE && !ignoreEvents && state != STATE_DRAGGING && !isPointInsideChildScrollView(parent, (int) event.getX(), (int) event.getY()) && viewDragHelper != null && Math.abs(initialY - event.getY()) > viewDragHelper.getTouchSlop(); }
Example 17
Source File: MovableTouchListener.java From Noyze with Apache License 2.0 | 4 votes |
@Override public boolean onTouch(View v, MotionEvent event) { if (null != mAnimator && mAnimator.isRunning()) return false; if (null == mPopupWindow) return false; switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: LayoutParams params = mPopupWindow.getWindowParams(); aPID = event.getPointerId(0); downX = (int) (params.x - event.getRawX()); downY = (int) (params.y - event.getRawY()); break; case MotionEvent.ACTION_UP: // Handle "snapping" to the right/ left edge of the screen. if (null != mAnchor) { final Rect mBounds = mPopupWindow.getBounds(); final int[] screen = mPopupWindow.getWindowDimensions(); switch (mAnchor) { case AXIS_Y: if (mBounds.left + (mBounds.width() / 2) > (screen[0] / 2)) { // Snap right. snap(screen[0] - mBounds.width(), PopupWindow.POSITION_UNCHANGED); } else { // Snap left. snap(0, PopupWindow.POSITION_UNCHANGED); } break; case AXIS_X: if (mBounds.top + (mBounds.height() / 2) > (screen[1] / 2)) { // Snap bottom. snap(PopupWindow.POSITION_UNCHANGED, screen[1] - mBounds.height()); } else { // Snap top. snap(PopupWindow.POSITION_UNCHANGED, 0); } break; case EDGES: if (mBounds.top + (mBounds.height() / 2) > (screen[1] / 2)) { // Snap bottom half. if (mBounds.left + (mBounds.width() / 2) > (screen[0] / 2)) // Snap bottom right. snap(screen[0] - mBounds.width(), screen[1] - mBounds.height()); else // Snap bottom left. snap(0, screen[1] - mBounds.height()); } else { // Snap top half. if (mBounds.left + (mBounds.width() / 2) > (screen[0] / 2)) // Snap top right. snap(screen[0] - mBounds.width(), 0); else // Snap top left. snap(0, 0); } break; } } break; case MotionEvent.ACTION_POINTER_UP: // Extract the index of the pointer that left the touch sensor final int pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; final int pointerId = event.getPointerId(pointerIndex); if (pointerId == aPID) { // This was our active pointer going up. Choose a new // active pointer and adjust accordingly. final int newPointerIndex = (pointerIndex == 0) ? 1 : 0; aPID = event.getPointerId(newPointerIndex); } case MotionEvent.ACTION_MOVE: // Find the index of the active pointer and fetch its position final int mPID = event.findPointerIndex(aPID); float xMove = event.getRawX(); float yMove = event.getRawY(); // From http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html final int dx = (int) (xMove + downX); final int dy = (int) (yMove + downY); mPopupWindow.position(((lockX) ? PopupWindow.POSITION_UNCHANGED : dx), ((lockY) ? PopupWindow.POSITION_UNCHANGED : dy)); break; case MotionEvent.ACTION_CANCEL: aPID = MotionEvent.INVALID_POINTER_ID; break; } return true; }