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

This code example shows how to use the following methods:getAction, getPointerCount, getX, getY
 
		return true; 
	} 
 
	final public boolean onTouchEvent(MotionEvent e) {
		final int action = e.getAction();
 
		// constants from APIv5: 
		// (action & ACTION_POINTER_INDEX_MASK) >> ACTION_POINTER_INDEX_SHIFT 
		final int pointer = (action & 0xff00) >> 8;
		 
		final int x0 = (int)e.getX();
		final int y0 = (int)e.getY();
		final int x1 = (e.getPointerCount() > 1 ? (int)e.getX(1) : -1);
		final int y1 = (e.getPointerCount() > 1 ? (int)e.getY(1) : -1);
		 
		if (pointer > 0) {
			_residualvm.pushEvent(JE_MULTI, pointer, action & 0xff, // ACTION_MASK
					x0, y0, x1, y1);
		} else { 
8
CodeRank
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
This code example shows how to use the following methods:getAction, getPointerCount, getX, getY
        } 
    } 
 
    @Override 
    public boolean onTouch(View v, MotionEvent event) {
        if (event.getPointerCount() > 1) {
            stopTracking(); 
        } 
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            if (!mIsTracking && event.getPointerCount() == 1) {
                long sinceLastScroll =
                        SystemClock.uptimeMillis() - mLastScrollTime;
                if (sinceLastScroll < IGNORE_INTERVAL) {
                    break; 
                } 
                mStartTouchY = event.getY();
                mStartTouchX = event.getX();
                mIsTracking = true;
                mHasTriggered = false;

7
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:getActionMasked, getPointerCount, getX, getY
        } 
        return mMoving == READY_MOVE || mMoving == MOVING;
    } 
     
    public boolean onTouch(View v, MotionEvent e) {
        float x1 = e.getPointerCount() > 0 ? e.getX(0) : 0;
        float y1 = e.getPointerCount() > 0 ? e.getY(0) : 0;
        float x2 = e.getPointerCount() > 1 ? e.getX(1) : x1;
        float y2 = e.getPointerCount() > 1 ? e.getY(1) : y1;
 
        onTouch_(v, e.getActionMasked(), e.getPointerCount(), x1, y1, x2, y2);
        return false;   // to call GestureDetector.onTouchEvent 
    } 
     
    public boolean onTouch(View v, int action, float x, float y) {
        if (action == MotionEvent.ACTION_DOWN) {
            mMoving = READY_MOVE;
            mPointCount = 0;
            mLastX = x;
            mLastY = y;
7
CodeRank
This code example shows how to use the following methods:getAction, getPointerCount, getX, getY
		* @return	void 
		*/ 
		@Override 
		public boolean onTouch( View v , MotionEvent e ) {
			 
			if( e.getPointerCount( ) == 2 ){
 
				switch( e.getAction( ) ){
 
					case MotionEvent.ACTION_DOWN:
 
		            case MotionEvent.ACTION_MOVE:
		            	rotation( e );
		                break; 
 
		            default: 
		            	 
				} 
 
				//rotation( e ); 

8
CodeRank
This code example shows how to use the following methods:getPointerCount, getX, getY
        } 
 
        @Override 
        public boolean onFling(final MotionEvent e1, final MotionEvent e2,
                final float velocityX, final float velocityY) {
            if ((e1.getPointerCount() > 1) || (e2.getPointerCount() > 1)) {
                return false; 
            } 
            if (ImageViewTouch.this.mScaleDetector.isInProgress()) {
                return false; 
            } 
 
            final float diffX = e2.getX() - e1.getX();
            final float diffY = e2.getY() - e1.getY();
 
            if ((Math.abs(velocityX) > 800) || (Math.abs(velocityY) > 800)) {
                scrollBy(diffX / 2, diffY / 2, 300);
                invalidate(); 
            } 
            return super.onFling(e1, e2, velocityX, velocityY);
7
CodeRank
This code example shows how to use the following methods:getAction, getPointerCount, getX, getY
	 *  
	 * @see it.sephiroth.android.library.imagezoom.ImageViewTouch#onTouchEvent(android.view.MotionEvent) 
	 */ 
	@Override 
	public boolean onTouchEvent( MotionEvent event ) {
		if ( mTouchMode == TouchMode.DRAW && event.getPointerCount() == 1 ) {
			float x = event.getX();
			float y = event.getY();
 
			switch ( event.getAction() ) {
				case MotionEvent.ACTION_DOWN:
					touch_start( x, y );
					invalidate(); 
					break; 
				case MotionEvent.ACTION_MOVE:
					touch_move( x, y );
					invalidate(); 
					break; 
				case MotionEvent.ACTION_UP:
					touch_up(); 

8
CodeRank
This code example shows how to use the following methods:getAction, getPointerCount, getX, getY
		init(); 
	} 
	 
	@Override 
	public boolean onTouch(View v, MotionEvent event) {
		if (event.getPointerCount() < 2) {
			((EmotionInterface) getActivity()).setLeftRightScrollable(true);
			return false; 
		} 
 
		boolean isDown = event.getAction() == (MotionEvent.ACTION_POINTER_DOWN | 0x0100);
		boolean isUp = (event.getAction() == (MotionEvent.ACTION_POINTER_UP | 0x0100))
				|| (event.getAction() == MotionEvent.ACTION_CANCEL)
				|| (event.getAction() == (MotionEvent.ACTION_POINTER_UP | 0x0000));
 
		if (isDown) {
			((EmotionInterface) getActivity()).setLeftRightScrollable(false);
 
			X1 = event.getX(0);
			Y1 = event.getY(0);

8
CodeRank
This code example shows how to use the following methods:getAction, getPointerCount, getX, getY
        mGestureDetector.onTouchEvent(event);
         
        float x = 0;
        float y = 0;
         
        switch (event.getAction() & MotionEvent.ACTION_MASK) {
             
            case MotionEvent.ACTION_DOWN:
                Log.i(TAG, "ACTION_DOWN count: " + event.getPointerCount());
                x = event.getX(event.getPointerCount()-1);
                y = event.getY(event.getPointerCount()-1);
                addSpot(x, y);
                return true; 
 
            case MotionEvent.ACTION_UP:
                Log.i(TAG, "ACTION_UP count: " + event.getPointerCount());
                return false; 
                 
            case MotionEvent.ACTION_POINTER_DOWN:
                Log.i(TAG, "ACTION_POINTER_DOWN count: " + event.getPointerCount());

6
CodeRank

Related MotionEvent getPointerCount Questions & Answers:

getPointerCount Method Overview
The number of pointers of data contained in this event.
See Code Examples for other Android MotionEvent Methods: