android.view.MotionEvent#transform ( )源码实例Demo

下面列出了android.view.MotionEvent#transform ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AcDisplay   文件: ViewUtils.java
/**
 * 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);
    }
}
 
源代码2 项目: AcDisplay   文件: ViewUtils.java
/**
 * 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);
    // }
}
 
源代码3 项目: HeadsUp   文件: ViewUtils.java
/**
 * 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);
    }
}
 
源代码4 项目: HeadsUp   文件: ViewUtils.java
/**
 * 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);
    // }
}
 
源代码5 项目: turbo-editor   文件: ViewUtils.java
/**
 * 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);
    }
}
 
源代码6 项目: turbo-editor   文件: ViewUtils.java
/**
 * 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);
    // }
}
 
源代码7 项目: Carbon   文件: TransformedLayout.java
@Override
public boolean dispatchTouchEvent(@NonNull MotionEvent event) {
    MotionEvent eventCopy = MotionEvent.obtain(event);
    eventCopy.transform(inverse);
    boolean result = super.dispatchTouchEvent(eventCopy);
    eventCopy.recycle();
    return result;
}
 
源代码8 项目: osmdroid   文件: MapView.java
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;
}
 
源代码9 项目: ViewSupport   文件: MotionEventHelper.java
@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
private static MotionEvent transformEventNew(MotionEvent e, Matrix m) {
    MotionEvent newEvent = MotionEvent.obtain(e);
    newEvent.transform(m);
    return newEvent;
}
 
源代码10 项目: GestureViews   文件: GestureControllerForPager.java
private static void transformToPagerEvent(MotionEvent event, View view, ViewPager pager) {
    tmpMatrix.reset();
    transformMatrixToPager(tmpMatrix, view, pager);
    event.transform(tmpMatrix);
}