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

This code example shows how to use the following methods:getAction, getActionIndex, getActionMasked, getX, obtainNoHistory
    } 
 
    @Override 
    public boolean dispatchTouchEvent(MotionEvent ev) {
        if (mWallpaperConnection != null && mWallpaperConnection.mEngine != null) {
            MotionEvent dup = MotionEvent.obtainNoHistory(ev);
            try { 
                mWallpaperConnection.mEngine.dispatchPointer(dup);
            } catch (RemoteException e) {
            } 
        } 
         
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            onUserInteraction();
        } 
        boolean handled = getWindow().superDispatchTouchEvent(ev);
        if (!handled) {
            handled = onTouchEvent(ev);
        } 
 

8
CodeRank
This code example shows how to use the following methods:getActionIndex, getActionMasked, getX
        destroyRenderer(); 
    } 
 
    @Override 
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getActionIndex() == 0) {
            float realPosition = mCurrentPosition + (event.getX() - mStartX);
            if (realPosition < 0.0f) {
                realPosition = 0.0f;
            } else if (realPosition > mWallpaperWidth * 4) {
                realPosition = mWallpaperWidth * 4;
            } 
 
            if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                mDragging = true;
                mStartX = event.getX(0);
            } else if (event.getActionMasked() == MotionEvent.ACTION_UP) {
                mDragging = false;
                mCurrentPosition = realPosition;
            } else if (mDragging) {

8
CodeRank
This code example shows how to use the following methods:getActionIndex, getActionMasked, getRawX, obtain, offsetLocation
	} 
 
	@Override 
	public boolean onTouch(View view, MotionEvent motionEvent) {
		// offset because the view is translated during swipe 
		motionEvent.offsetLocation(mTranslationX, 0);
 
		if (mViewWidth < 2) {
			mViewWidth = mView.getWidth();
		} 
 
		switch (motionEvent.getActionMasked()) {
		case MotionEvent.ACTION_DOWN: {
			// TODO: ensure this is a finger, and set a flag 
			mDownX = motionEvent.getRawX();
			mVelocityTracker = VelocityTracker.obtain();
			mVelocityTracker.addMovement(motionEvent);
			view.onTouchEvent(motionEvent);
			return false; 
		} 

8
CodeRank
This code example shows how to use the following methods:getActionIndex, getActionMasked, getRawX, getRawY, obtain
        this.dismissListener = dismissListener;
    } 
 
    @Override 
    public boolean onTouch(View v, MotionEvent e) {
        switch (e.getActionMasked()) {
            case MotionEvent.ACTION_DOWN:
                return handleActionDown(e);
 
            case MotionEvent.ACTION_MOVE:
                return handleActionMove(e);
 
            case MotionEvent.ACTION_UP:
                return handleActionUp(e);
 
            case MotionEvent.ACTION_CANCEL:
                return handleActionCancel(e);
 
            default: 
                return false; 

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: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:getActionIndex, getActionMasked, getPointerId, getX, getY
	public boolean onTouchEvent(MotionEvent event) {
		if (!handleTouchEvents) return false;
 
        boolean handled = false;
 
        int pointer_index = event.getActionIndex();
        int pointer_id = event.getPointerId(pointer_index);
        switch (event.getActionMasked()) {
            case MotionEvent.ACTION_POINTER_DOWN:
            case MotionEvent.ACTION_DOWN:
                if (type == Type.joystick && hitPuck(event, pointer_index)) {
                    draggingPuck = true;
                    draggingPuckPointerId = pointer_id;
                    handled = true;
                    if (touchMotionListener != null) {
                        touchMotionListener.onStart();
                    } 
                } else if (hitLeftBoostButton(event, pointer_index)) {
                    // boost!!! 
                    handled = true;

6
CodeRank

Related MotionEvent getActionIndex Questions & Answers:

getActionIndex Method Overview
For ACTION_POINTER_DOWN or ACTION_POINTER_UP as returned by getActionMasked(), this returns the associated pointer index.
See Code Examples for other Android MotionEvent Methods: