Java Code Examples for android.view.MotionEvent#getFlags()

The following examples show how to use android.view.MotionEvent#getFlags() . 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: StickyGridHeadersGridView.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
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 2
Source File: MotionEventHelper.java    From ViewSupport with Apache License 2.0 5 votes vote down vote up
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 3
Source File: AdUnitRelativeLayout.java    From unity-ads-android with Apache License 2.0 5 votes vote down vote up
@TargetApi(14)
public boolean onInterceptTouchEvent(MotionEvent e) {
	super.onInterceptTouchEvent(e);

	if (_shouldCapture) {
		if (_motionEvents.size() < _maxEvents) {
			boolean isObscured = (e.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0;
			synchronized (_motionEvents) {
				_motionEvents.add(new AdUnitMotionEvent(e.getActionMasked(), isObscured, e.getToolType(0), e.getSource(), e.getDeviceId(), e.getX(0), e.getY(0), e.getEventTime(), e.getPressure(0), e.getSize(0)));
			}
		}
	}

	return false;
}
 
Example 4
Source File: StickyGridHeadersGridView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
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 vote down vote up
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: EditorActivity.java    From APDE with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
	/*
	 * See comments for isTouchObscured above.
	 */
	
	isTouchObscured = (event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0;
	return super.dispatchTouchEvent(event);
}
 
Example 7
Source File: ObsdAlertDialog.java    From FreezeYou with Apache License 2.0 4 votes vote down vote up
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    isObsd = (ev.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0;
    return super.dispatchTouchEvent(ev);
}