List of usage examples for android.view MotionEvent ACTION_POINTER_DOWN
int ACTION_POINTER_DOWN
To view the source code for android.view MotionEvent ACTION_POINTER_DOWN.
Click Source Link
From source file:com.gq.widget.loop.LoopViewPager.java
/** * ?//from w w w .j a v a2s. com */ @Override public boolean onTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN || ev.getAction() == MotionEvent.ACTION_POINTER_DOWN) {// setAutoLoop(false, mDelayTime); } else if (ev.getAction() == MotionEvent.ACTION_UP) { if (mIsAutoLoop) { if (mHandler == null) { mHandler = new InnerHandler(); mHandler.sendEmptyMessageDelayed(0, mDelayTime); } else { mHandler.removeCallbacksAndMessages(null); mHandler.sendEmptyMessageDelayed(0, mDelayTime); } } else { if (mHandler != null) { mHandler.removeCallbacksAndMessages(null); mHandler = null; } } } return super.onTouchEvent(ev); }
From source file:org.uoyabause.android.PadButton.java
public boolean onTouch(View v, MotionEvent event) { int action = event.getActionMasked(); int touchCount = event.getPointerCount(); int pointerIndex = event.getActionIndex(); int pointerId = event.getPointerId(pointerIndex); int posx = (int) event.getX(pointerIndex); int posy = (int) event.getY(pointerIndex); float hitsize = 15.0f * wscale * base_scale; RectF hittest = new RectF((int) (posx - hitsize), (int) (posy - hitsize), (int) (posx + hitsize), (int) (posy + hitsize)); switch (action) { case MotionEvent.ACTION_DOWN: for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) { if (buttons[btnindex].intersects(hittest)) { buttons[btnindex].On(pointerId); }/* w ww. ja v a 2 s .co m*/ } if (_pad_mode == 1) { updatePad(hittest, posx, posy, pointerId); } break; case MotionEvent.ACTION_POINTER_DOWN: for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) { if (buttons[btnindex].intersects(hittest)) { buttons[btnindex].On(pointerId); } } if (_pad_mode == 1) { updatePad(hittest, posx, posy, pointerId); } break; case MotionEvent.ACTION_POINTER_UP: for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) { if (buttons[btnindex].intersects(hittest)) { buttons[btnindex].Off(); } } if (_pad_mode == 1) { releasePad(pointerId); } break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) { if (buttons[btnindex].intersects(hittest)) { buttons[btnindex].Off(); } } if (_pad_mode == 1) { releasePad(pointerId); } break; case MotionEvent.ACTION_MOVE: for (int index = 0; index < touchCount; index++) { int eventID2 = event.getPointerId(index); float x2 = event.getX(index); float y2 = event.getY(index); RectF hittest2 = new RectF((int) (x2 - hitsize), (int) (y2 - hitsize), (int) (x2 + hitsize), (int) (y2 + hitsize)); for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) { if (eventID2 == buttons[btnindex].getPointId()) { if (buttons[btnindex].intersects(hittest2) == false) { buttons[btnindex].Off(); } } else if (buttons[btnindex].intersects(hittest2)) { buttons[btnindex].On(eventID2); } } if (_pad_mode == 1) { updatePad(hittest2, (int) x2, (int) y2, eventID2); } } break; } if (!testmode) { if (_pad_mode == 0) { for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) { if (buttons[btnindex].isOn()) { YabauseRunnable.press(btnindex, 0); } else { YabauseRunnable.release(btnindex, 0); } } } else { for (int btnindex = PadEvent.BUTTON_RIGHT_TRIGGER; btnindex < PadEvent.BUTTON_LAST; btnindex++) { if (buttons[btnindex].isOn()) { YabauseRunnable.press(btnindex, 0); } else { YabauseRunnable.release(btnindex, 0); } } } } if (testmode) { status = ""; status += "START:"; if (buttons[PadEvent.BUTTON_START].isOn()) status += "ON "; else status += "OFF "; status += "\nUP:"; if (buttons[PadEvent.BUTTON_UP].isOn()) status += "ON "; else status += "OFF "; status += "DOWN:"; if (buttons[PadEvent.BUTTON_DOWN].isOn()) status += "ON "; else status += "OFF "; status += "LEFT:"; if (buttons[PadEvent.BUTTON_LEFT].isOn()) status += "ON "; else status += "OFF "; status += "RIGHT:"; if (buttons[PadEvent.BUTTON_RIGHT].isOn()) status += "ON "; else status += "OFF "; status += "\nA:"; if (buttons[PadEvent.BUTTON_A].isOn()) status += "ON "; else status += "OFF "; status += "B:"; if (buttons[PadEvent.BUTTON_B].isOn()) status += "ON "; else status += "OFF "; status += "C:"; if (buttons[PadEvent.BUTTON_C].isOn()) status += "ON "; else status += "OFF "; status += "\nX:"; if (buttons[PadEvent.BUTTON_X].isOn()) status += "ON "; else status += "OFF "; status += "Y:"; if (buttons[PadEvent.BUTTON_Y].isOn()) status += "ON "; else status += "OFF "; status += "Z:"; if (buttons[PadEvent.BUTTON_Z].isOn()) status += "ON "; else status += "OFF "; status += "\nLT:"; if (buttons[PadEvent.BUTTON_LEFT_TRIGGER].isOn()) status += "ON "; else status += "OFF "; status += "RT:"; if (buttons[PadEvent.BUTTON_RIGHT_TRIGGER].isOn()) status += "ON "; else status += "OFF "; status += "\nAX:"; if (_analog_pad.isOn()) status += "ON " + _axi_x; else status += "OFF " + _axi_x; status += "AY:"; if (_analog_pad.isOn()) status += "ON " + _axi_y; else status += "OFF " + _axi_y; } if ((listener != null)) { listener.onPad(null); } return true; }
From source file:com.heneryh.aquanotes.ui.controllers.GraphsFragment.java
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 va2 s . c o m break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: //When the gesture ends, a thread is created to give inertia to the scrolling and zoom final Timer t = new Timer(); t.schedule(new TimerTask() { @Override public void run() { while (Math.abs(lastScrolling) > 1f || Math.abs(lastZooming - 1) < 1.01) { lastScrolling *= .8; //speed of scrolling damping scroll(lastScrolling); lastZooming += (1 - lastZooming) * .2; //speed of zooming damping zoom(lastZooming); checkBoundaries(); try { mySimpleXYPlot.postRedraw(); } catch (final InterruptedException e) { e.printStackTrace(); } // the thread lives until the scrolling and zooming are imperceptible } } }, 0); 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) { final PointF oldFirstFinger = firstFinger; firstFinger = new PointF(event.getX(), event.getY()); lastScrolling = oldFirstFinger.x - firstFinger.x; scroll(lastScrolling); lastZooming = (firstFinger.y - oldFirstFinger.y) / mySimpleXYPlot.getHeight(); if (lastZooming < 0) lastZooming = 1 / (1 - lastZooming); else lastZooming += 1; zoom(lastZooming); checkBoundaries(); mySimpleXYPlot.redraw(); } else if (mode == TWO_FINGERS_DRAG) { final float oldDist = distBetweenFingers; distBetweenFingers = spacing(event); lastZooming = oldDist / distBetweenFingers; zoom(lastZooming); checkBoundaries(); mySimpleXYPlot.redraw(); } break; } return true; }
From source file:org.cocos2dx.lib.TextInputWraper.java
private void dumpEvent(MotionEvent event) { String names[] = { "DOWN", "UP", "MOVE", "CANCEL", "OUTSIDE", "POINTER_DOWN", "POINTER_UP", "7?", "8?", "9?" }; StringBuilder sb = new StringBuilder(); int action = event.getAction(); int actionCode = action & MotionEvent.ACTION_MASK; sb.append("event ACTION_").append(names[actionCode]); if (actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP) { sb.append("(pid ").append(action >> MotionEvent.ACTION_POINTER_ID_SHIFT); sb.append(")"); }//from ww w . j a v a 2 s.c om sb.append("["); for (int i = 0; i < event.getPointerCount(); i++) { sb.append("#").append(i); sb.append("(pid ").append(event.getPointerId(i)); sb.append(")=").append((int) event.getX(i)); sb.append(",").append((int) event.getY(i)); if (i + 1 < event.getPointerCount()) sb.append(";"); } sb.append("]"); Log.d(TAG, sb.toString()); }
From source file:com.android.mail.browse.ConversationContainer.java
/** * Touch slop code was copied from {@link ScrollView#onInterceptTouchEvent(MotionEvent)}. *///from w w w .j av a 2 s . co m @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (!mTouchInitialized) { mTouchInitialized = true; } // no interception when WebView handles the first DOWN if (mWebView.isHandlingTouch()) { return false; } boolean intercept = false; switch (ev.getActionMasked()) { case MotionEvent.ACTION_POINTER_DOWN: LogUtils.d(TAG, "Container is intercepting non-primary touch!"); intercept = true; mMissedPointerDown = true; requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_DOWN: mLastMotionY = ev.getY(); mActivePointerId = ev.getPointerId(0); break; case MotionEvent.ACTION_MOVE: final int pointerIndex = ev.findPointerIndex(mActivePointerId); final float y = ev.getY(pointerIndex); final int yDiff = (int) Math.abs(y - mLastMotionY); if (yDiff > mTouchSlop) { mLastMotionY = y; intercept = true; } break; } // LogUtils.v(TAG, "in Container.InterceptTouch. action=%d x/y=%f/%f pointers=%d result=%s", // ev.getActionMasked(), ev.getX(), ev.getY(), ev.getPointerCount(), intercept); return intercept; }
From source file:io.mariachi.allianzvision.camera.api14.Camera1.java
@Override public boolean onTouch(View view, MotionEvent event) { Log.e("log", "touchevent"); Camera.Parameters params = mCamera.getParameters(); int action = event.getAction(); if (event.getPointerCount() > 1) { if (action == MotionEvent.ACTION_POINTER_DOWN) { mDistance = getFingerSpacing(event); } else if (action == MotionEvent.ACTION_MOVE && params.isZoomSupported()) { mCamera.cancelAutoFocus();//from w w w . j ava 2s. c om handleZoom(event, params); } } else { // handle single touch events if (action == MotionEvent.ACTION_UP) { handleFocus(event, params); } } return true; }
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. j a v a 2s.c o 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.android.mail.browse.ConversationContainer.java
@Override public boolean onTouchEvent(MotionEvent ev) { final int action = ev.getActionMasked(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { mTouchIsDown = false;//from w w w. j av a 2 s. c om } else if (!mTouchIsDown && (action == MotionEvent.ACTION_MOVE || action == MotionEvent.ACTION_POINTER_DOWN)) { forwardFakeMotionEvent(ev, MotionEvent.ACTION_DOWN); if (mMissedPointerDown) { forwardFakeMotionEvent(ev, MotionEvent.ACTION_POINTER_DOWN); mMissedPointerDown = false; } mTouchIsDown = true; } final boolean webViewResult = mWebView.onTouchEvent(ev); // LogUtils.v(TAG, "in Container.OnTouch. action=%d x/y=%f/%f pointers=%d", // ev.getActionMasked(), ev.getX(), ev.getY(), ev.getPointerCount()); return webViewResult; }
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 w w. j av a2 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.wordplat.ikvstockchart.InteractiveKLineView.java
@Override public boolean onTouchEvent(MotionEvent e) { final int action = MotionEventCompat.getActionMasked(e); gestureDetector.onTouchEvent(e);/* w w w .ja v a 2 s. com*/ scaleDetector.onTouchEvent(e); switch (action) { case MotionEvent.ACTION_DOWN: { onTouch = true; onDragging = false; break; } case MotionEvent.ACTION_POINTER_DOWN: { onDoubleFingerPress = true; break; } case MotionEvent.ACTION_MOVE: { onDragging = true; if (onLongPress) { highlight(e.getX(), e.getY()); } break; } case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: { onLongPress = false; onDoubleFingerPress = false; onTouch = false; onDragging = false; cancelHighlight(); break; } } return true; }