MotionEvent findPointerIndex - 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 findPointerIndex method.

This code example shows how to use the following methods:findPointerIndex, getAction, getPointerCount, getX, getY
 
	@Override 
	public boolean onTouchEvent(MotionEvent event) {
		 
 
		int action = event.getAction();
		if (event.getPointerCount()>1){
			int actionEvent = action & MotionEvent.ACTION_MASK;
			int actionPointerId= action & MotionEvent.ACTION_POINTER_INDEX_MASK;
			 
			// Find the index of the pointer 
			int index = event.findPointerIndex(actionPointerId);
			 
			// Gets its coordinates 
			float eventX = event.getX(index);
			float eventY = event.getY(index);
			 
			// TODO Do something with the data 
			 
		} 
 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:findPointerIndex, getAction, getPointerCount, getPointerId, getX
        if (!isEnabled())
            return false; 
 
        int pointerIndex;
 
        final int action = event.getAction();
        switch (action & MotionEvent.ACTION_MASK) {
 
            case MotionEvent.ACTION_DOWN:
                // Remember where the motion event started 
                mActivePointerId = event.getPointerId(event.getPointerCount() - 1);
                pointerIndex = event.findPointerIndex(mActivePointerId);
                mDownMotionX = event.getX(pointerIndex);
 
                pressedThumb = evalPressedThumb(mDownMotionX);
 
                // Only handle thumb presses. 
                if (pressedThumb == null)
                    return super.onTouchEvent(event);
 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:findPointerIndex, getEventTime, getPressure, getX, getY
 
    private void setContext(View view, MotionEvent curr) {
        if (mCurrEvent != null) {
            mCurrEvent.recycle();
        } 
        mCurrEvent = MotionEvent.obtain(curr);
 
        mCurrLen = -1;
        mPrevLen = -1;
        mScaleFactor = -1;
        mCurrSpanVector.set(0.0f, 0.0f);
 
        final MotionEvent prev = mPrevEvent;
 
        final int prevIndex0 = prev.findPointerIndex(mActiveId0);
        final int prevIndex1 = prev.findPointerIndex(mActiveId1);
        final int currIndex0 = curr.findPointerIndex(mActiveId0);
        final int currIndex1 = curr.findPointerIndex(mActiveId1);
 
        if (prevIndex0 < 0 || prevIndex1 < 0 || currIndex0 < 0 || currIndex1 < 0) {

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:findPointerIndex, getX, getY
	public StateMoveAll(EditorView editorView, TweetFlow tweetFlow) {
		super(editorView, tweetFlow);
	} 
	 
	public void onActionMove(MotionEvent event) {
		final int pointerIndex = event.findPointerIndex(mEditorView.getActivePointerId());
        final int x = (int)event.getX(pointerIndex);
        final int y = (int)event.getY(pointerIndex);
	    if(!mEditorView.scaleDetectorActive()) { 
	        final int offX = x - mEditorView.getLastTouchX();
			final int offY = y - mEditorView.getLastTouchY();
				 
			mEditorView.offset(offX, offY);
			mEditorView.redraw(); 
	    } 
		mEditorView.setLastTouch(x, y);	
	}	 
	 
	public void onActionUp(MotionEvent event) {
		super.onActionUp(event);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:findPointerIndex, getPressure, getX, getY
		return false; 
	} 
	 
	private boolean processMoveEvent(MotionEvent ev) {
		if ( pointerId != INVALID_POINTER_ID ) {
			final int pointerIndex = ev.findPointerIndex(pointerId);
			 
			// Translate touch position to center of view 
			float x = ev.getX(pointerIndex);
			touchX = x - cX - offsetX;
			float y = ev.getY(pointerIndex);
			touchY = y - cY - offsetY;
 
//        	Log.d(TAG, String.format("ACTION_MOVE: (%03.0f, %03.0f) => (%03.0f, %03.0f)", x, y, touchX, touchY)); 
        	 
			reportOnMoved(); 
			invalidate();
			 
			touchPressure = ev.getPressure(pointerIndex);
			reportOnPressure(); 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:findPointerIndex, getAction, getPointerId, getX, getY
            } 
        } 
 
        @Override 
        public boolean onTouchEvent(MotionEvent ev) {
            final int action = ev.getAction();
            switch (action & MotionEvent.ACTION_MASK) {
                case MotionEvent.ACTION_DOWN:
                    mActivePointerId = ev.getPointerId(0);
                    break; 
                case MotionEvent.ACTION_CANCEL:
                case MotionEvent.ACTION_UP:
                    mActivePointerId = INVALID_POINTER_ID;
                    break; 
                case MotionEvent.ACTION_POINTER_UP:
                    final int pointerIndex = (ev.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.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. 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:findPointerIndex, getAction, getPointerCount, getPointerId, getX
		if (!isEnabled())
			return false; 
 
		int pointerIndex;
 
		final int action = event.getAction();
		switch (action & MotionEvent.ACTION_MASK) {
 
		case MotionEvent.ACTION_DOWN:
			// Remember where the motion event started 
			mActivePointerId = event.getPointerId(event.getPointerCount() - 1);
			pointerIndex = event.findPointerIndex(mActivePointerId);
			mDownMotionX = event.getX(pointerIndex);
 
			pressedThumb = evalPressedThumb(mDownMotionX);
 
			// Only handle thumb presses. 
			if (pressedThumb == null)
				return super.onTouchEvent(event);
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:findPointerIndex, getAction, getPointerId, getX, MotionEvent.getY
 
            /* 
             * Shortcut the most recurring case: the user is in the dragging state and he is moving his finger. We want to 
             * intercept this motion. 
             */ 
            final int action = ev.getAction();
            if ((action == MotionEvent.ACTION_MOVE) && (touchState != TOUCH_STATE_REST)) {
                return true; 
            } 
 
            if (mVelocityTracker == null) {
                mVelocityTracker = VelocityTracker.obtain();
            } 
            mVelocityTracker.addMovement(ev);
 
    //      switch (action & MotionEvent.ACTION_MASK) { 
            switch (action) {
            case MotionEvent.ACTION_MOVE:
 
    //          Log.d("workspace","Intercepted a move event"); 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:findPointerIndex, getAction, getPointerCount, getPointerId, getX
		if (!isEnabled())
			return false; 
 
		int pointerIndex;
 
		final int action = event.getAction();
		switch (action & MotionEvent.ACTION_MASK) {
 
		case MotionEvent.ACTION_DOWN:
			// Remember where the motion event started 
			mActivePointerId = event.getPointerId(event.getPointerCount() - 1);
			pointerIndex = event.findPointerIndex(mActivePointerId);
			mDownMotionX = event.getX(pointerIndex);
 
			pressedThumb = evalPressedThumb(mDownMotionX);
 
			// Only handle thumb presses. 
			if (!pressedThumb)
				return super.onTouchEvent(event);
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:findPointerIndex, getPressure, getX, getY
		return false; 
	} 
	 
	private boolean processMoveEvent(MotionEvent ev) {
		if ( pointerId != INVALID_POINTER_ID ) {
			final int pointerIndex = ev.findPointerIndex(pointerId);
			 
			// Translate touch position to center of view 
			float x = ev.getX(pointerIndex);
			touchX = x - cX - offsetX;
			float y = ev.getY(pointerIndex);
			touchY = y - cY - offsetY;
 
//        	Log.d(TAG, String.format("ACTION_MOVE: (%03.0f, %03.0f) => (%03.0f, %03.0f)", x, y, touchX, touchY)); 
        	 
			reportOnMoved(); 
			invalidate();
			 
			touchPressure = ev.getPressure(pointerIndex);
			reportOnPressure(); 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related MotionEvent findPointerIndex Questions & Answers:

findPointerIndex Method Overview
Given a pointer identifier, find the index of its data in the event.
See Code Examples for other Android MotionEvent Methods: