List of usage examples for android.view MotionEvent getPointerCount
public final int getPointerCount()
From source file:Main.java
private static MotionEvent transformEventOld(MotionEvent e, Matrix m) { long downTime = e.getDownTime(); long eventTime = e.getEventTime(); int action = e.getAction(); int pointerCount = e.getPointerCount(); int[] pointerIds = getPointerIds(e); PointerCoords[] pointerCoords = getPointerCoords(e); int metaState = e.getMetaState(); float xPrecision = e.getXPrecision(); float yPrecision = e.getYPrecision(); int deviceId = e.getDeviceId(); int edgeFlags = e.getEdgeFlags(); int source = e.getSource(); int flags = e.getFlags(); // Copy the x and y coordinates into an array, map them, and copy back. float[] xy = new float[pointerCoords.length * 2]; for (int i = 0; i < pointerCount; i++) { xy[2 * i] = pointerCoords[i].x;/* www. ja va2 s . c o m*/ xy[2 * i + 1] = pointerCoords[i].y; } m.mapPoints(xy); for (int i = 0; i < pointerCount; i++) { pointerCoords[i].x = xy[2 * i]; pointerCoords[i].y = xy[2 * i + 1]; pointerCoords[i].orientation = transformAngle(m, pointerCoords[i].orientation); } MotionEvent n = MotionEvent.obtain(downTime, eventTime, action, pointerCount, pointerIds, pointerCoords, metaState, xPrecision, yPrecision, deviceId, edgeFlags, source, flags); return n; }
From source file:Main.java
public static JSONObject CreateJSonObjectFromMotionEvent(MotionEvent e) throws JSONException { JSONObject jObj = new JSONObject(); jObj.put("downTime", e.getDownTime()); jObj.put("eventTime", e.getEventTime()); jObj.put("action", e.getAction()); jObj.put("pointerCount", e.getPointerCount()); jObj.put("metaState", e.getMetaState()); jObj.put("buttonState", e.getButtonState()); jObj.put("xPrecision", e.getXPrecision()); jObj.put("yPrecision", e.getYPrecision()); jObj.put("deviceId", e.getDeviceId()); jObj.put("edgeFlags", e.getEdgeFlags()); jObj.put("source", e.getSource()); jObj.put("flags", e.getFlags()); for (int i = 0; i < e.getPointerCount(); i++) { PointerProperties prop = new PointerProperties(); e.getPointerProperties(i, prop); PointerCoords coords = new PointerCoords(); e.getPointerCoords(i, coords);//from w ww . j av a2s.co m JSONObject pointer = JObjFromPointer(prop, coords); jObj.accumulate("pointers", pointer); } return jObj; }
From source file:Main.java
public static void velocityTrackerPointerUpCleanUpIfNecessary(MotionEvent ev, VelocityTracker tracker) { // Check the dot product of current velocities. // If the pointer that left was opposing another velocity vector, clear. tracker.computeCurrentVelocity(1000, mMaximumFlingVelocity); final int upIndex = ev.getActionIndex(); final int id1 = ev.getPointerId(upIndex); final float x1 = tracker.getXVelocity(id1); final float y1 = tracker.getYVelocity(id1); for (int i = 0, count = ev.getPointerCount(); i < count; i++) { if (i == upIndex) continue; final int id2 = ev.getPointerId(i); final float x = x1 * tracker.getXVelocity(id2); final float y = y1 * tracker.getYVelocity(id2); final float dot = x + y; if (dot < 0) { tracker.clear();// www . j a v a 2s. co m break; } } }
From source file:com.google.android.apps.santatracker.dasherdancer.NoSwipeViewPager.java
@Override public boolean onTouchEvent(MotionEvent ev) { boolean retVal = false; if (ev.getPointerCount() > 1) { retVal = mScaleGestureDetector.onTouchEvent(ev); }//from w ww . j a va 2 s. c o m if (!retVal && ev.getPointerCount() == 1) { retVal = mGestureDetector.onTouchEvent(ev) || retVal; } return retVal; }
From source file:com.stfalcon.frescoimageviewer.MultiTouchViewPager.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (ev.getPointerCount() > 1) { return false; } else {/* www . j a va 2s . c o m*/ try { return super.onInterceptTouchEvent(ev); } catch (IllegalArgumentException ex) { return false; } } }
From source file:com.netease.hearttouch.htimagepicker.core.view.photoview.PhotoViewPager.java
@Override public boolean dispatchTouchEvent(@NonNull MotionEvent ev) { if (ev.getPointerCount() > 1 && mIsDisallowIntercept) { requestDisallowInterceptTouchEvent(false); boolean handled = super.dispatchTouchEvent(ev); requestDisallowInterceptTouchEvent(true); return handled; } else {//from www.j av a 2s . c om return super.dispatchTouchEvent(ev); } }
From source file:com.stfalcon.frescoimageviewer.MultiTouchViewPager.java
@Override public boolean dispatchTouchEvent(@NonNull MotionEvent ev) { if (ev.getPointerCount() > 1 && isDisallowIntercept) { requestDisallowInterceptTouchEvent(false); boolean handled = super.dispatchTouchEvent(ev); requestDisallowInterceptTouchEvent(true); return handled; } else {//from w w w .j a v a 2 s . c om return super.dispatchTouchEvent(ev); } }
From source file:com.google.android.apps.forscience.whistlepunk.MultiTouchDrawerLayout.java
@Override public boolean dispatchTouchEvent(MotionEvent ev) { // the incorrect array size will only happen in the multi-touch scenario. if (ev.getPointerCount() > 1 && mIsDisallowIntercept) { requestDisallowInterceptTouchEvent(false); boolean handled = super.dispatchTouchEvent(ev); requestDisallowInterceptTouchEvent(true); return handled; } else {/*from w w w.j a va2 s .c om*/ return super.dispatchTouchEvent(ev); } }
From source file:org.skia.viewer.ViewerActivity.java
@Override public boolean onTouch(View v, MotionEvent event) { int count = event.getPointerCount(); for (int i = 0; i < count; i++) { final float x = event.getX(i); final float y = event.getY(i); final int owner = event.getPointerId(i); int action = event.getAction() & MotionEvent.ACTION_MASK; onTouched(mApplication.getNativeHandle(), owner, action, x, y); }/*from www .j a v a 2 s.c om*/ return true; }
From source file:danonino.danonino_the_game.Core.Labels.PowerUp.java
public int onTouch(MotionEvent event) { int index = MotionEventCompat.getActionIndex(event); int x;//from w ww. j a v a 2 s . co m int y; if (event.getPointerCount() > 1) { // The coordinates of the current screen contact, relative to // the responding View or Activity. x = (int) MotionEventCompat.getX(event, index); y = (int) MotionEventCompat.getY(event, index); } else { // Single touch event x = (int) MotionEventCompat.getX(event, index); y = (int) MotionEventCompat.getY(event, index); } if (this.usePowerUpBtn.btn_rect.contains(x, y) || ((event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_POINTER_UP) && usePowerUpBtnPressed)) { this.usePowerUpBtnPressed = !this.usePowerUpBtnPressed; this.usePowerUpBtn.onTouch(event); return 1; } return 0; }