List of usage examples for android.view MotionEvent ACTION_POINTER_UP
int ACTION_POINTER_UP
To view the source code for android.view MotionEvent ACTION_POINTER_UP.
Click Source Link
From source file:com.jest.phone.PhoneActivity.java
@Override public boolean onTouch(View arg0, MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: // Start gesture firstFinger = new PointF(event.getX(), event.getY()); mode = ONE_FINGER_DRAG;/*from w w w.ja va2s . co m*/ stopThread = true; break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: mode = NONE; break; case MotionEvent.ACTION_POINTER_DOWN: // second finger distBetweenFingers = spacing(event); // the distance check is done to avoid false alarms if (distBetweenFingers > 5f) { mode = TWO_FINGERS_DRAG; } break; case MotionEvent.ACTION_MOVE: if (mode == ONE_FINGER_DRAG) { PointF oldFirstFinger = firstFinger; firstFinger = new PointF(event.getX(), event.getY()); scroll(oldFirstFinger.x - firstFinger.x); sensorHistoryPlot.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.FIXED); sensorHistoryPlot.redraw(); } else if (mode == TWO_FINGERS_DRAG) { float oldDist = distBetweenFingers; distBetweenFingers = spacing(event); zoom(oldDist / distBetweenFingers); sensorHistoryPlot.setDomainBoundaries(minXY.x, maxXY.x, BoundaryMode.FIXED); sensorHistoryPlot.redraw(); } break; } return true; }
From source file:com.coco.slidinguppanel.SlidingUpPanel.java
@Override public boolean onTouchEvent(MotionEvent ev) { if (getState() == STATE_OPENED) { // disable touch handle when in opened state. return false; }/*from w w w . j a v a 2 s .co m*/ final int action = MotionEventCompat.getActionMasked(ev); if (action == MotionEvent.ACTION_DOWN && ev.getEdgeFlags() != 0) { // Don't handle edge touches immediately -- they may actually belong to one of our descendants. return false; } if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(ev); switch (action) { case MotionEvent.ACTION_DOWN: { onTouchDown(ev, false); DEBUG_LOG("Down at " + mLastMotionX + "," + mLastMotionY + " mIsBeingDragged=" + mIsBeingDragged + " mIsUnableToDrag=" + mIsUnableToDrag); break; } case MotionEvent.ACTION_MOVE: { final int activePointerId = mActivePointerId; if (activePointerId == INVALID_POINTER || mIsUnableToDrag) { // 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 y = MotionEventCompat.getY(ev, pointerIndex); final float xDiff = Math.abs(x - mInitialMotionX); final float yDiff = Math.abs(y - mInitialMotionY); DEBUG_LOG("Moved to " + x + "," + y + " diff=" + xDiff + "," + yDiff); onTouchMove(x, y, xDiff, yDiff, false); break; } case MotionEvent.ACTION_UP: { if (mIsBeingDragged) { final VelocityTracker velocityTracker = mVelocityTracker; velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); final int initialVelocity = (int) VelocityTrackerCompat.getYVelocity(velocityTracker, mActivePointerId); final int pointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); final float y = MotionEventCompat.getY(ev, pointerIndex); final int totalDelta = (int) (y - mInitialMotionY); boolean toOpen = determineToOpen(initialVelocity, totalDelta); startFling(toOpen, initialVelocity); endDrag(); } DEBUG_LOG("Touch up!!!"); break; } case MotionEvent.ACTION_CANCEL: { if (mIsBeingDragged) { startFling(isOpen(), 0); endDrag(); } DEBUG_LOG("Touch cancel!!!"); break; } case MotionEventCompat.ACTION_POINTER_DOWN: { final int pointerIndex = MotionEventCompat.getActionIndex(ev); final float x = MotionEventCompat.getX(ev, pointerIndex); final float y = MotionEventCompat.getY(ev, pointerIndex); mLastMotionX = x; mLastMotionY = y; mActivePointerId = MotionEventCompat.getPointerId(ev, pointerIndex); break; } case MotionEvent.ACTION_POINTER_UP: onTouchPointerUp(ev); break; } return true; }
From source file:com.cloverstudio.spika.CameraCropActivity.java
@Override public boolean onTouch(View v, MotionEvent event) { ImageView view = (ImageView) v; switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: savedMatrix.set(matrix);//from w ww .ja v a2s . c om start.set(event.getX(), event.getY()); mode = DRAG; break; case MotionEvent.ACTION_POINTER_DOWN: oldDist = spacing(event); if (oldDist > 10f) { savedMatrix.set(matrix); midPoint(mid, event); mode = ZOOM; } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: mode = NONE; break; case MotionEvent.ACTION_MOVE: if (mode == DRAG) { // ... matrix.set(savedMatrix); matrix.postTranslate(event.getX() - start.x, event.getY() - start.y); start_x = event.getX() - start.x; start_y = event.getY() - start.y; } else if (mode == ZOOM) { float newDist = spacing(event); if (newDist > 10f) { matrix.set(savedMatrix); float scale = newDist / oldDist; mAspect = scale; matrix.postScale(scale, scale, mid.x, mid.y); } } break; } view.setImageMatrix(matrix); view.invalidate(); return true; }
From source file:com.leeon.blank.widget.RangeBarNew.java
@Override public boolean onTouchEvent(MotionEvent event) { getParent().requestDisallowInterceptTouchEvent(false); // For multiple touch final int action = event.getActionMasked(); switch (action) { case MotionEvent.ACTION_DOWN: downY = event.getY();/* w ww . j av a 2 s. c o m*/ handleTouchDown(event); break; case MotionEvent.ACTION_POINTER_DOWN: handleTouchDown(event); break; case MotionEvent.ACTION_MOVE: final float yDiff = Math.abs(event.getY() - downY); if (yDiff > mTouchSlop) { return false; } else { getParent().requestDisallowInterceptTouchEvent(true); handleTouchMove(event); } break; case MotionEvent.ACTION_POINTER_UP: handleTouchUp(event); break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: handleTouchUp(event); break; } return super.onTouchEvent(event); }
From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java
@Override public boolean onTouch(View v, MotionEvent event) { switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: { multipleFingersCountingTime = false; multipleFingersStartTime = 0L;/*from w w w. j av a 2 s . c o m*/ multipleFingersTime = 0L; break; } case MotionEvent.ACTION_POINTER_DOWN: { if (!multipleFingersCountingTime) { multipleFingersCountingTime = true; multipleFingersStartTime = System.currentTimeMillis(); } break; } case MotionEvent.ACTION_POINTER_UP: { if (event.getPointerCount() <= 2) { if (multipleFingersCountingTime) { multipleFingersCountingTime = false; multipleFingersTime += System.currentTimeMillis() - multipleFingersStartTime; } } break; } } return false; }
From source file:eu.hydrologis.geopaparazzi.chart.ProfileChartActivity.java
@Override public boolean onTouch(View arg0, MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: // Start gesture firstFinger = new PointF(event.getX(), event.getY()); mode = ONE_FINGER_DRAG;//from w ww. j a va 2 s. co m stopThread = true; break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: mode = NONE; break; case MotionEvent.ACTION_POINTER_DOWN: // second finger distBetweenFingers = spacing(event); // the distance check is done to avoid false alarms if (distBetweenFingers > 5f) { mode = TWO_FINGERS_DRAG; } break; case MotionEvent.ACTION_MOVE: if (mode == ONE_FINGER_DRAG) { PointF oldFirstFinger = firstFinger; firstFinger = new PointF(event.getX(), event.getY()); scrollElev(oldFirstFinger.x - firstFinger.x); scrollSpeed(oldFirstFinger.x - firstFinger.x); xyPlotSpeed.setDomainBoundaries(minXYSpeed.x, maxXYSpeed.x, BoundaryMode.FIXED); xyPlotElev.setDomainBoundaries(minXYElevation.x, maxXYElevation.x, BoundaryMode.FIXED); xyPlotSpeed.redraw(); xyPlotElev.redraw(); } else if (mode == TWO_FINGERS_DRAG) { float oldDist = distBetweenFingers; distBetweenFingers = spacing(event); zoomElev(oldDist / distBetweenFingers); zoomSpeed(oldDist / distBetweenFingers); xyPlotSpeed.setDomainBoundaries(minXYSpeed.x, maxXYSpeed.x, BoundaryMode.FIXED); xyPlotElev.setDomainBoundaries(minXYElevation.x, maxXYElevation.x, BoundaryMode.FIXED); xyPlotSpeed.redraw(); xyPlotElev.redraw(); } break; } return true; }
From source file:org.protocoderrunner.apprunner.AppRunnerActivity.java
@Override public boolean onGenericMotionEvent(MotionEvent event) { int action = event.getAction(); int actionCode = event.getActionMasked(); ArrayList<PPadView.TouchEvent> t = new ArrayList<PPadView.TouchEvent>(); // check finger if down or up if (actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP) { }//from www.ja v a2 s.com if (event.getSource() == MotionEvent.TOOL_TYPE_MOUSE) { // if (event.getButtonState() == ac) { // } } // get positions per finger for (int i = 0; i < event.getPointerCount(); i++) { // TouchEvent o = new TouchEvent("finger", event.getPointerId(i), // action, (int) event.getX(), // (int) event.getY()); // t.add(o); } // // FINGER 1 UP x y // FINGER 2 MOVE x y // MOUSE 3 MOVE x y // return touching; return super.onGenericMotionEvent(event); }
From source file:chenyoufu.hciprojectes10.MyGLSurfaceView.java
@Override public boolean onTouchEvent(MotionEvent event) { int action = MotionEventCompat.getActionMasked(event); int index = MotionEventCompat.getActionIndex(event); if (event.getPointerCount() > 1) { if (action == MotionEvent.ACTION_POINTER_UP && event.getPointerCount() == 2) { xOri = MotionEventCompat.getX(event, 1 - index); yOri = MotionEventCompat.getY(event, 1 - index); }// w ww. j a va2 s. c o m mScaleDetector.onTouchEvent(event); } else { switch (action) { case MotionEvent.ACTION_DOWN: xOri = MotionEventCompat.getX(event, index); yOri = MotionEventCompat.getY(event, index); break; case MotionEvent.ACTION_MOVE: float xNow = MotionEventCompat.getX(event, index); float yNow = MotionEventCompat.getY(event, index); float[] xMove = Global.fArrayMul(Global.getCamCrossProductNV(), (xOri - xNow) / Global.moveFactor); Global.cameraEye = Global.fArrayAdd(Global.cameraEye, xMove); Global.cameraCentre = Global.fArrayAdd(Global.cameraCentre, xMove); float[] yMove = Global.fArrayMul(Global.cameraUp, (yNow - yOri) / Global.moveFactor); Global.cameraEye = Global.fArrayAdd(Global.cameraEye, yMove); Global.cameraCentre = Global.fArrayAdd(Global.cameraCentre, yMove); xOri = xNow; yOri = yNow; break; default: break; } } requestRender(); return true; }
From source file:com.bulletnoid.android.widget.StaggeredGridView.StaggeredGridView3.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { int action = ev.getAction(); View v;//from w ww . j av a 2 s. co m switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: { int touchMode = mTouchMode; final int x = (int) ev.getX(); final int y = (int) ev.getY(); mActivePointerId = ev.getPointerId(0); int motionPosition = findMotionRow(y); if (touchMode != TOUCH_MODE_FLINGING && motionPosition >= 0) { // User clicked on an actual view (and was not stopping a fling). // Remember where the motion event started v = getChildAt(motionPosition - mFirstPosition); //mMotionViewOriginalTop=v.getTop(); mLastTouchX = x; mLastTouchY = y; mMotionPosition = motionPosition; mTouchMode = TOUCH_MODE_DOWN; clearScrollingCache(); } mTouchRemainderY = Integer.MIN_VALUE; if (touchMode == TOUCH_MODE_FLINGING) { return true; } break; } case MotionEvent.ACTION_MOVE: { switch (mTouchMode) { case TOUCH_MODE_DOWN: final int pointerIndex = ev.findPointerIndex(mActivePointerId); final int y = (int) ev.getY(pointerIndex); if (startScrollIfNeeded((int) (y - mLastTouchX))) { return true; } break; } break; } case MotionEvent.ACTION_UP: { mTouchMode = TOUCH_MODE_REST; mActivePointerId = INVALID_POINTER; reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE); break; } case MotionEvent.ACTION_POINTER_UP: { onSecondaryPointerUp(ev); break; } } return false; }
From source file:org.stockchart.StockChartView.java
private boolean handleTouchEvent(MotionEvent ev) { int e = ev.getAction() & MotionEvent.ACTION_MASK; switch (e) {/* w w w.ja va 2 s. c o m*/ case MotionEvent.ACTION_DOWN: { fMode = TouchMode.DRAG; fDragStartPoint.set(ev.getX(), ev.getY()); } break; case MotionEvent.ACTION_POINTER_DOWN: { fOldDist = getSpacing(ev); if (fOldDist > 10) fMode = TouchMode.ZOOM; } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: { if (e == MotionEvent.ACTION_UP) { if (!fTouchEventHandled) this.onTouchEventUp(ev); fTouchEventHandled = false; } if (fMode == TouchMode.DRAG) processCrosshair(ev.getX(), ev.getY()); fMode = TouchMode.NONE; } break; case MotionEvent.ACTION_MOVE: { if (TouchMode.ZOOM == fMode) { float newDist = getSpacing(ev); if (newDist > 10f) { float scale = newDist - fOldDist; this.zoom(inPercentsOfWidth(scale), inPercentsOfHeight(scale)); invalidate(); fTouchEventHandled = true; } } else if (TouchMode.DRAG == fMode) { float dx = fDragStartPoint.x - ev.getX(); float dy = ev.getY() - fDragStartPoint.y; if (dx != 0f || dy != 0f) { this.move(inPercentsOfWidth(dx), inPercentsOfHeight(dy)); invalidate(); fTouchEventHandled = true; } } processCrosshair(ev.getX(), ev.getY()); } break; } return true; }