Java Code Examples for android.view.MotionEvent#getXPrecision()
The following examples show how to use
android.view.MotionEvent#getXPrecision() .
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: TouchPaint.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override public boolean onTrackballEvent(MotionEvent event) { final int action = event.getActionMasked(); if (action == MotionEvent.ACTION_DOWN) { // Advance color when the trackball button is pressed. advanceColor(); } if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE) { final int N = event.getHistorySize(); final float scaleX = event.getXPrecision() * TRACKBALL_SCALE; final float scaleY = event.getYPrecision() * TRACKBALL_SCALE; for (int i = 0; i < N; i++) { moveTrackball(event.getHistoricalX(i) * scaleX, event.getHistoricalY(i) * scaleY); } moveTrackball(event.getX() * scaleX, event.getY() * scaleY); } return true; }
Example 2
Source File: StickyGridHeadersGridView.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private MotionEvent transformEvent(MotionEvent e, int headerPosition) { if (headerPosition == MATCHED_STICKIED_HEADER) { return e; } long downTime = e.getDownTime(); long eventTime = e.getEventTime(); int action = e.getAction(); int pointerCount = e.getPointerCount(); int[] pointerIds = getPointerIds(e); MotionEvent.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(); View headerHolder = getChildAt(headerPosition); for (int i = 0; i < pointerCount;i++) { pointerCoords[i].y -= headerHolder.getTop(); } MotionEvent n = MotionEvent.obtain(downTime, eventTime, action, pointerCount, pointerIds, pointerCoords, metaState, xPrecision, yPrecision, deviceId, edgeFlags, source, flags); return n; }
Example 3
Source File: MotionEventHelper.java From ViewSupport with Apache License 2.0 | 5 votes |
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; 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; }
Example 4
Source File: StickyGridHeadersGridView.java From UltimateAndroid with Apache License 2.0 | 5 votes |
private MotionEvent transformEvent(MotionEvent e, int headerPosition) { if (headerPosition == MATCHED_STICKIED_HEADER) { return e; } long downTime = e.getDownTime(); long eventTime = e.getEventTime(); int action = e.getAction(); int pointerCount = e.getPointerCount(); int[] pointerIds = getPointerIds(e); MotionEvent.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(); View headerHolder = getChildAt(headerPosition); for (int i = 0; i < pointerCount;i++) { pointerCoords[i].y -= headerHolder.getTop(); } MotionEvent n = MotionEvent.obtain(downTime, eventTime, action, pointerCount, pointerIds, pointerCoords, metaState, xPrecision, yPrecision, deviceId, edgeFlags, source, flags); return n; }
Example 5
Source File: StickyGridHeadersGridView.java From StickyGridHeaders with Apache License 2.0 | 5 votes |
private MotionEvent transformEvent(MotionEvent e, int headerPosition) { if (headerPosition == MATCHED_STICKIED_HEADER) { return e; } long downTime = e.getDownTime(); long eventTime = e.getEventTime(); int action = e.getAction(); int pointerCount = e.getPointerCount(); int[] pointerIds = getPointerIds(e); MotionEvent.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(); View headerHolder = getChildAt(headerPosition); for (int i = 0; i < pointerCount;i++) { pointerCoords[i].y -= headerHolder.getTop(); } MotionEvent n = MotionEvent.obtain(downTime, eventTime, action, pointerCount, pointerIds, pointerCoords, metaState, xPrecision, yPrecision, deviceId, edgeFlags, source, flags); return n; }
Example 6
Source File: MapView.java From Androzic with GNU General Public License v3.0 | 5 votes |
@Override public boolean onTrackballEvent(MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_UP: setFollowingThroughContext(!isFollowing); break; case MotionEvent.ACTION_MOVE: if (!isFollowing) { int n = event.getHistorySize(); final float scaleX = event.getXPrecision(); final float scaleY = event.getYPrecision(); int dx = (int) (-event.getX() * scaleX); int dy = (int) (-event.getY() * scaleY); for (int i = 0; i < n; i++) { dx += -event.getHistoricalX(i) * scaleX; dy += -event.getHistoricalY(i) * scaleY; } if (Math.abs(dx) > 0 || Math.abs(dy) > 0) { onDragFinished(dx, dy); } } break; } /* * for (MapOverlay mo : this.overlays) if (mo.onTrackballEvent(event, * this)) return true; */ return true; }