Java Code Examples for android.view.MotionEvent#transform()
The following examples show how to use
android.view.MotionEvent#transform() .
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: ViewUtils.java From AcDisplay with GNU General Public License v2.0 | 6 votes |
/** * Recursive helper method that applies transformations in post-order. * * @param ev the on-screen motion event */ private static void transformMotionEventToLocal(@NonNull View view, @NonNull MotionEvent ev) { final ViewParent parent = view.getParent(); if (parent instanceof View) { final View vp = (View) parent; transformMotionEventToLocal(vp, ev); ev.offsetLocation(vp.getScrollX(), vp.getScrollY()); } // TODO: Use reflections to access ViewRootImpl // else if (parent instanceof ViewRootImpl) { // final ViewRootImpl vr = (ViewRootImpl) parent; // ev.offsetLocation(0, vr.mCurScrollY); // } ev.offsetLocation(-view.getLeft(), -view.getTop()); Matrix matrix = view.getMatrix(); if (matrix != null) { ev.transform(matrix); } }
Example 2
Source File: ViewUtils.java From AcDisplay with GNU General Public License v2.0 | 6 votes |
/** * Recursive helper method that applies transformations in pre-order. * * @param ev the on-screen motion event */ private static void transformMotionEventToGlobal(@NonNull View view, @NonNull MotionEvent ev) { Matrix matrix = view.getMatrix(); if (matrix != null) { ev.transform(matrix); } ev.offsetLocation(view.getLeft(), view.getTop()); final ViewParent parent = view.getParent(); if (parent instanceof View) { final View vp = (View) parent; ev.offsetLocation(-vp.getScrollX(), -vp.getScrollY()); transformMotionEventToGlobal(vp, ev); } // TODO: Use reflections to access ViewRootImpl // else if (parent instanceof ViewRootImpl) { // final ViewRootImpl vr = (ViewRootImpl) parent; // ev.offsetLocation(0, -vr.mCurScrollY); // } }
Example 3
Source File: ViewUtils.java From HeadsUp with GNU General Public License v2.0 | 6 votes |
/** * Recursive helper method that applies transformations in post-order. * * @param ev the on-screen motion event */ private static void transformMotionEventToLocal(@NonNull View view, @NonNull MotionEvent ev) { final ViewParent parent = view.getParent(); if (parent instanceof View) { final View vp = (View) parent; transformMotionEventToLocal(vp, ev); ev.offsetLocation(vp.getScrollX(), vp.getScrollY()); } // TODO: Use reflections to access ViewRootImpl // else if (parent instanceof ViewRootImpl) { // final ViewRootImpl vr = (ViewRootImpl) parent; // ev.offsetLocation(0, vr.mCurScrollY); // } ev.offsetLocation(-view.getLeft(), -view.getTop()); Matrix matrix = view.getMatrix(); if (matrix != null) { ev.transform(matrix); } }
Example 4
Source File: ViewUtils.java From HeadsUp with GNU General Public License v2.0 | 6 votes |
/** * Recursive helper method that applies transformations in pre-order. * * @param ev the on-screen motion event */ private static void transformMotionEventToGlobal(@NonNull View view, @NonNull MotionEvent ev) { Matrix matrix = view.getMatrix(); if (matrix != null) { ev.transform(matrix); } ev.offsetLocation(view.getLeft(), view.getTop()); final ViewParent parent = view.getParent(); if (parent instanceof View) { final View vp = (View) parent; ev.offsetLocation(-vp.getScrollX(), -vp.getScrollY()); transformMotionEventToGlobal(vp, ev); } // TODO: Use reflections to access ViewRootImpl // else if (parent instanceof ViewRootImpl) { // final ViewRootImpl vr = (ViewRootImpl) parent; // ev.offsetLocation(0, -vr.mCurScrollY); // } }
Example 5
Source File: ViewUtils.java From turbo-editor with GNU General Public License v3.0 | 6 votes |
/** * Recursive helper method that applies transformations in post-order. * * @param ev the on-screen motion event */ private static void transformMotionEventToLocal(@NonNull View view, @NonNull MotionEvent ev) { final ViewParent parent = view.getParent(); if (parent instanceof View) { final View vp = (View) parent; transformMotionEventToLocal(vp, ev); ev.offsetLocation(vp.getScrollX(), vp.getScrollY()); } // TODO: Use reflections to access ViewRootImpl // else if (parent instanceof ViewRootImpl) { // final ViewRootImpl vr = (ViewRootImpl) parent; // ev.offsetLocation(0, vr.mCurScrollY); // } ev.offsetLocation(-view.getLeft(), -view.getTop()); Matrix matrix = view.getMatrix(); if (matrix != null) { ev.transform(matrix); } }
Example 6
Source File: ViewUtils.java From turbo-editor with GNU General Public License v3.0 | 6 votes |
/** * Recursive helper method that applies transformations in pre-order. * * @param ev the on-screen motion event */ private static void transformMotionEventToGlobal(@NonNull View view, @NonNull MotionEvent ev) { Matrix matrix = view.getMatrix(); if (matrix != null) { ev.transform(matrix); } ev.offsetLocation(view.getLeft(), view.getTop()); final ViewParent parent = view.getParent(); if (parent instanceof View) { final View vp = (View) parent; ev.offsetLocation(-vp.getScrollX(), -vp.getScrollY()); transformMotionEventToGlobal(vp, ev); } // TODO: Use reflections to access ViewRootImpl // else if (parent instanceof ViewRootImpl) { // final ViewRootImpl vr = (ViewRootImpl) parent; // ev.offsetLocation(0, -vr.mCurScrollY); // } }
Example 7
Source File: TransformedLayout.java From Carbon with Apache License 2.0 | 5 votes |
@Override public boolean dispatchTouchEvent(@NonNull MotionEvent event) { MotionEvent eventCopy = MotionEvent.obtain(event); eventCopy.transform(inverse); boolean result = super.dispatchTouchEvent(eventCopy); eventCopy.recycle(); return result; }
Example 8
Source File: MapView.java From osmdroid with Apache License 2.0 | 5 votes |
private MotionEvent rotateTouchEvent(MotionEvent ev) { if (this.getMapOrientation() == 0) return ev; MotionEvent rotatedEvent = MotionEvent.obtain(ev); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { getProjection().unrotateAndScalePoint((int) ev.getX(), (int) ev.getY(), mRotateScalePoint); rotatedEvent.setLocation(mRotateScalePoint.x, mRotateScalePoint.y); } else { // This method is preferred since it will rotate historical touch events too rotatedEvent.transform(getProjection().getInvertedScaleRotateCanvasMatrix()); } return rotatedEvent; }
Example 9
Source File: MotionEventHelper.java From ViewSupport with Apache License 2.0 | 4 votes |
@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) private static MotionEvent transformEventNew(MotionEvent e, Matrix m) { MotionEvent newEvent = MotionEvent.obtain(e); newEvent.transform(m); return newEvent; }
Example 10
Source File: GestureControllerForPager.java From GestureViews with Apache License 2.0 | 4 votes |
private static void transformToPagerEvent(MotionEvent event, View view, ViewPager pager) { tmpMatrix.reset(); transformMatrixToPager(tmpMatrix, view, pager); event.transform(tmpMatrix); }