MotionEvent getPointerId - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MotionEvent getPointerId method.

This code example shows how to use the following methods:getAction, getPointerId, getPressure, getX, getY
	public void onClick(View view) {
	} 
 
	@Override 
	public boolean onDoubleTap(MotionEvent event) {
		final int action = event.getAction();
		final int pointerIndex = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
        final int pointerId = event.getPointerId(pointerIndex);
 
        OFAndroid.onTouchDoubleTap(pointerId, event.getX(pointerIndex), event.getY(pointerIndex), event.getPressure(pointerIndex));
 
		return true; 
		//return super.onDoubleTap(e); 
	} 
	 
	@Override 
	public boolean onDoubleTapEvent(MotionEvent event) {
		return super.onDoubleTapEvent(event);
	} 
 
10
CodeRank
This code example shows how to use the following methods:getAction, getPointerId, getX, MotionEvent.getY
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        mScaleDetector.onTouchEvent(ev);
 
        boolean ret = false;
        float x = ev.getX();
        float y = ev.getY();
 
        final int action = ev.getAction();
 
        switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN: {
            mRender.onActionDown(x, y);
            mActivePointerId = ev.getPointerId(0);
            ret = true;
            break; 
        } 
        case MotionEvent.ACTION_MOVE: {
            if (!mScaleDetector.isInProgress()) {
                mRender.onActionMove(x, y);

8
CodeRank
This code example shows how to use the following methods:getAction, getPointerId, getX, MotionEvent.getY
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        mScaleDetector.onTouchEvent(ev);
 
        boolean ret = false;
        float x = ev.getX();
        float y = ev.getY();
 
        final int action = ev.getAction();
 
        switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN: {
            mRender.onActionDown(x, y);
            mActivePointerId = ev.getPointerId(0);
            ret = true;
            break; 
        } 
        case MotionEvent.ACTION_MOVE: {
            if (!mScaleDetector.isInProgress()) {
                mRender.onActionMove(x, y);

8
CodeRank
This code example shows how to use the following methods:getAction, getActionMasked, getPointerCount, getPointerId, getX
    } 
     
    @Override 
    public boolean onTouch(View v, MotionEvent event) {
         
        if (event.getPointerCount() == 2 &&
            event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
            return onMultiTouchEvent(v, event);
        } 
         
        switch(event.getAction()){
            case MotionEvent.ACTION_DOWN: {
                downX = event.getX();
                downY = event.getY();
                lastDownPointerId = event.getPointerId(0);
                return true; 
            } 
            case MotionEvent.ACTION_UP: {
                upX = event.getX();
                upY = event.getY();

7
CodeRank
This code example shows how to use the following methods:getAction, getPointerId, getX, MotionEvent.getY
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        mScaleDetector.onTouchEvent(ev);
 
        boolean ret = false;
        float x = ev.getX();
        float y = ev.getY();
 
        final int action = ev.getAction();
 
        switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN: {
            mRender.onActionDown(x, y);
            mActivePointerId = ev.getPointerId(0);
            ret = true;
            break; 
        } 
        case MotionEvent.ACTION_MOVE: {
            if (!mScaleDetector.isInProgress()) {
                mRender.onActionMove(x, y);

8
CodeRank
This code example shows how to use the following methods:getAction, getPointerId, getX
        } 
        return true; 
    } 
 
    private final void onSecondaryPointerUp(MotionEvent ev) {
        final int pointerIndex = (ev.getAction() & ACTION_POINTER_INDEX_MASK) >> ACTION_POINTER_INDEX_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. 
            // TODO: Make this decision more intelligent. 
            final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
            mDownMotionX = ev.getX(newPointerIndex);
            mActivePointerId = ev.getPointerId(newPointerIndex);
        } 
    } 
 
    private final void trackTouchEvent(MotionEvent event) {
        final int pointerIndex = event.findPointerIndex(mActivePointerId);
7
CodeRank
This code example shows how to use the following methods:getAction, getPointerId, getX, MotionEvent.getY
    @Override 
    public boolean onTouchEvent(MotionEvent ev) {
        mScaleDetector.onTouchEvent(ev);
 
        boolean ret = false;
        float x = ev.getX();
        float y = ev.getY();
 
        final int action = ev.getAction();
 
        switch (action & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN: {
            mRender.onActionDown(x, y);
            mActivePointerId = ev.getPointerId(0);
            ret = true;
            break; 
        } 
        case MotionEvent.ACTION_MOVE: {
            if (!mScaleDetector.isInProgress()) {
                mRender.onActionMove(x, y);

8
CodeRank
This code example shows how to use the following methods:getActionIndex, getPointerId, getPointerIdBits
        final long deltaTime = secondUp.getEventTime() - firstUp.getEventTime();
        return (deltaTime >= timeout);
    } 
 
    public static boolean isSamePointerContext(MotionEvent first, MotionEvent second) {
        return (first.getPointerIdBits() == second.getPointerIdBits()
                && first.getPointerId(first.getActionIndex())
                        == second.getPointerId(second.getActionIndex()));
    } 
 
    /** 
     * Determines whether a two pointer gesture is a dragging one. 
     * 
     * @param event The event with the pointer data. 
     * @return True if the gesture is a dragging one. 
     */ 
    public static boolean isDraggingGesture(float firstPtrDownX, float firstPtrDownY,
            float secondPtrDownX, float secondPtrDownY, float firstPtrX, float firstPtrY,
            float secondPtrX, float secondPtrY, float maxDraggingAngleCos) {
 
6
CodeRank
This code example shows how to use the following methods:getAction, getActionIndex, getPointerId
 
    private String getEvent(MotionEvent event)
    { 
 
	StringBuilder sb = new StringBuilder();
	int action = event.getAction();
	int actionCode = action & MotionEvent.ACTION_MASK;
	//sb.append("code").append( actionCode ); 
	if (actionCode == MotionEvent.ACTION_MOVE) {
	    sb.append("{move:[").append(moveBuffer).append("]}");
	} else if (actionCode == MotionEvent.ACTION_POINTER_DOWN
		|| actionCode == MotionEvent.ACTION_DOWN) {
	    sb.append("{down:").append(moveBuffer).append("}");
	} else if (actionCode == MotionEvent.ACTION_POINTER_UP
		|| actionCode == MotionEvent.ACTION_UP) {
	    sb.append("{up:").append(event.getPointerId(event.getActionIndex())).append("}");
	} else if (actionCode == MotionEvent.ACTION_CANCEL) {
	    sb.append("{cancel:").append(event.getPointerId(event.getActionIndex()));
	} 
 

6
CodeRank
This code example shows how to use the following methods:getAction, getPointerId, getX
	public static final int INVALID_POINTER_ID = -1;
	private int pointerId = INVALID_POINTER_ID;
	private int countdown;
	@Override 
	public boolean onTouchEvent(MotionEvent event) {
		final int action = event.getAction();
		switch (action & MotionEvent.ACTION_MASK) {
			case MotionEvent.ACTION_MOVE: {if(pointerId!= INVALID_POINTER_ID) return true;}
			case MotionEvent.ACTION_CANCEL:
			case MotionEvent.ACTION_UP: {
				if(pointerId != INVALID_POINTER_ID) {
					release(); 
				} 
				break; 
			} 
			case MotionEvent.ACTION_POINTER_UP:{
				if(pointerId != INVALID_POINTER_ID){
			        final int p = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
			        if(event.getPointerId(p) == this.pointerId){
			        	release(); 

6
CodeRank

Related MotionEvent getPointerId Questions & Answers:

getPointerId Method Overview
Return the pointer identifier associated with a particular pointer data index is this event.
See Code Examples for other Android MotionEvent Methods: