Java Code Examples for android.view.MotionEvent#ACTION_POINTER_ID_MASK

The following examples show how to use android.view.MotionEvent#ACTION_POINTER_ID_MASK . 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: TrendScrollViewWidget.java    From LotteryTrend with Apache License 2.0 5 votes vote down vote up
private void onSecondaryPointerUp(MotionEvent ev) {
	final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
	final int pointerId = ev.getPointerId(pointerIndex);
	if (pointerId == mActivePointerId) {
		// This was our active pointer going up. Choose a new
		// active pointer and adjust accordingly.
		final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
		mLastMotionX = ev.getX(newPointerIndex);
		mLastMotionY = ev.getY(newPointerIndex);
		mActivePointerId = ev.getPointerId(newPointerIndex);
		if (mVelocityTracker != null) {
			mVelocityTracker.clear();
		}
	}
}
 
Example 2
Source File: Compat.java    From narrate-android with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 3
Source File: Compat.java    From zen4android with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 4
Source File: Compat.java    From MultiView with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 5
Source File: Compat.java    From BlackLight with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 6
Source File: Compat.java    From Tweetin with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 7
Source File: Compat.java    From android-project-wo2b with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 8
Source File: Compat.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 9
Source File: Compat.java    From RotatePhotoView with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 10
Source File: JoystickView.java    From RobotCA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {

    // Touch events indicate user wants to reset calibration in Tilt mode
    if (controlMode == ControlMode.Tilt) {

        // Reset calibration
        tiltOffset = null;

        return true;
    }

    final int action = event.getAction();

    switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_MOVE: {
            // If the primary contact point is no longer on the screen then ignore
            // the event.
            if (pointerId != INVALID_POINTER_ID) {
                // If the virtual joystick is in resume-previous-velocity mode.
                if (previousVelocityMode) {
                    // And the current contact is close to the contact location prior to
                    // ContactUp.
                    if (inLastContactRange(event.getX(event.getActionIndex()),
                            event.getY(event.getActionIndex()))) {
                        // Then use the previous velocity.
                        onContactMove(contactUpLocation.x + joystickRadius, contactUpLocation.y
                                + joystickRadius);
                    }
                    // Since the current contact is not close to the prior location.
                    else {
                        // Exit the resume-previous-velocity mode.
                        previousVelocityMode = false;
                    }
                }
                // Since the resume-previous-velocity mode is not active generate
                // velocities based on current contact position.
                else {
                    onContactMove(event.getX(event.findPointerIndex(pointerId)),
                            event.getY(event.findPointerIndex(pointerId)));
                }
            }
            break;
        }
        case MotionEvent.ACTION_DOWN: {
            // Get the coordinates of the pointer that is initiating the
            // interaction.
            pointerId = event.getPointerId(event.getActionIndex());
            onContactDown();
            // If the current contact is close to the location of the contact prior
            // to contactUp.
            if (inLastContactRange(event.getX(event.getActionIndex()), event.getY(event.getActionIndex()))) {
                // Trigger resume-previous-velocity mode.
                previousVelocityMode = true;
                // The animation calculations/operations are performed in
                // onContactMove(). If this is not called and the user's finger stays
                // perfectly still after the down event, no operation is performed.
                // Calling onContactMove avoids this.
                onContactMove(contactUpLocation.x + joystickRadius, contactUpLocation.y + joystickRadius);
            } else {
                onContactMove(event.getX(event.getActionIndex()), event.getY(event.getActionIndex()));
            }
            break;
        }
        case MotionEvent.ACTION_POINTER_UP:
        case MotionEvent.ACTION_UP: {
            // Check if the contact that initiated the interaction is up.
            //noinspection deprecation
            if ((action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT == pointerId) {
                onContactUp();
            }
            break;
        }
    }
    return true;
}
 
Example 11
Source File: Compat.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 12
Source File: Compat.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 13
Source File: Compat.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 14
Source File: Compat.java    From Android with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 15
Source File: CropCompat.java    From ImagePicker with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action)
{
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 16
Source File: TouchNavigationMethod.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
final protected int getPointerId(MotionEvent e) {
    return (e.getAction() & MotionEvent.ACTION_POINTER_ID_MASK)
            >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 17
Source File: TouchNavigationMethod.java    From CodeEditor with Apache License 2.0 4 votes vote down vote up
final protected int getPointerId(MotionEvent e) {
    return (e.getAction() & MotionEvent.ACTION_POINTER_ID_MASK)
            >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 18
Source File: CropCompat.java    From ImageSelector with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
 return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 19
Source File: Compat.java    From Favorite-Android-Client with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ECLAIR)
private static int getPointerIndexEclair(int action) {
    return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}
 
Example 20
Source File: TouchNavigationMethod.java    From CodeEditor with Apache License 2.0 4 votes vote down vote up
final protected int getPointerId(MotionEvent e) {
    return (e.getAction() & MotionEvent.ACTION_POINTER_ID_MASK)
            >> MotionEvent.ACTION_POINTER_ID_SHIFT;
}