Java Code Examples for android.view.MotionEvent#ACTION_POINTER_1_UP

The following examples show how to use android.view.MotionEvent#ACTION_POINTER_1_UP . 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: TextSticker.java    From EasyPhotos with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {

    gestureDetector.onTouchEvent(event);
    if (MotionEvent.ACTION_UP == event.getAction() || MotionEvent.ACTION_POINTER_UP == event.getAction() || MotionEvent.ACTION_POINTER_1_UP == event.getAction() || MotionEvent.ACTION_POINTER_2_UP == event.getAction()) {
        setDoubleDownPoints(0, 0, 0, 0);
        lastDoubleDegress = 1000;
        lastDegree = computeDegree(new Point((int) dstPs[4], (int) dstPs[5]), new Point((int) dstPs[8], (int) dstPs[9]));
    }

    return !isOut;
}
 
Example 2
Source File: BitmapSticker.java    From EasyPhotos with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {

    gestureDetector.onTouchEvent(event);
    if (MotionEvent.ACTION_UP == event.getAction() || MotionEvent.ACTION_POINTER_UP == event.getAction() || MotionEvent.ACTION_POINTER_1_UP == event.getAction() || MotionEvent.ACTION_POINTER_2_UP == event.getAction()) {
        setDoubleDownPoints(0, 0, 0, 0);
        lastDoubleDegress = 1000;
        lastDegree = computeDegree(new Point((int) dstPs[4], (int) dstPs[5]), new Point((int) dstPs[8], (int) dstPs[9]));
    }

    return !isOut;
}
 
Example 3
Source File: TextSticker.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {

    gestureDetector.onTouchEvent(event);
    if (MotionEvent.ACTION_UP == event.getAction() || MotionEvent.ACTION_POINTER_UP == event.getAction() || MotionEvent.ACTION_POINTER_1_UP == event.getAction() || MotionEvent.ACTION_POINTER_2_UP == event.getAction()) {
        setDoubleDownPoints(0, 0, 0, 0);
        lastDoubleDegress = 1000;
        lastDegree = computeDegree(new Point((int) dstPs[4], (int) dstPs[5]), new Point((int) dstPs[8], (int) dstPs[9]));
    }

    return !isOut;
}
 
Example 4
Source File: BitmapSticker.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {

    gestureDetector.onTouchEvent(event);
    if (MotionEvent.ACTION_UP == event.getAction() || MotionEvent.ACTION_POINTER_UP == event.getAction() || MotionEvent.ACTION_POINTER_1_UP == event.getAction() || MotionEvent.ACTION_POINTER_2_UP == event.getAction()) {
        setDoubleDownPoints(0, 0, 0, 0);
        lastDoubleDegress = 1000;
        lastDegree = computeDegree(new Point((int) dstPs[4], (int) dstPs[5]), new Point((int) dstPs[8], (int) dstPs[9]));
    }

    return !isOut;
}
 
Example 5
Source File: RotateGestureDetector.java    From Mp4Composer-android with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
synchronized public boolean onTouchEvent(MotionEvent event) {

    float eventX = event.getX();
    float eventY = event.getY();
    int count = event.getPointerCount();

    switch (event.getAction() & MotionEvent.ACTION_MASK) {
        case MotionEvent.ACTION_DOWN:
            downX = eventX;
            downY = eventY;
            if (count >= 2) {
                downX2 = event.getX(1);
                downY2 = event.getY(1);
            }
            break;
        case MotionEvent.ACTION_POINTER_DOWN:
            downX2 = event.getX(1);
            downY2 = event.getY(1);
            break;
        case MotionEvent.ACTION_MOVE:

            if (count >= 2) {

                // 回転角度の取得
                float angle = getAngle(downX, downY, downX2, downY2, eventX, eventY, event.getX(1), event.getY(1));

                // 画像の回転
                if (angle != SLOPE_0) {
                    this.angle -= angle * 180d / Math.PI;
                }

                downX2 = event.getX(1);
                downY2 = event.getY(1);

                if (rotationGestureListener != null) {
                    rotationGestureListener.onRotation(getDeltaAngle());
                }
            }

            break;
        case MotionEvent.ACTION_POINTER_UP:
            switch (event.getAction()) {
                case MotionEvent.ACTION_POINTER_1_UP:
                    isFirstPointerUp = true;
                    break;
                default:
            }
            break;
        default:
    }

    if (isFirstPointerUp) {
        downX = downX2;
        downY = downY2;
        isFirstPointerUp = false;
    } else {
        downX = eventX;
        downY = eventY;
    }

    return true;
}
 
Example 6
Source File: DragPinchListener.java    From AndroidPDF with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onTouch(View v, MotionEvent event) {
    mView = v ;
    switch (event.getAction()) {

        // NORMAL CASE : FIRST POINTER DOWN
        case MotionEvent.ACTION_DOWN:
            // Start dragging
            startDrag(event);
            state = State.DRAG;
            lastDownX = event.getX();
            lastDownY = event.getY();
            break;

        // NORMAL CASE : SECOND POINTER DOWN
        case MotionEvent.ACTION_POINTER_2_DOWN:
            startDrag(event);
            startZoom(event);
            state = State.ZOOM;
            break;

        // NORMAL CASE : SECOND POINTER UP
        case MotionEvent.ACTION_POINTER_2_UP:
            // End zooming, goes back to dragging
            state = State.DRAG;
            break;

        // NORMAL CASE : FIRST POINTER UP
        case MotionEvent.ACTION_UP:
            // End everything
            state = State.NONE;
            endDrag();

            // Treat clicks
            if (isClick(event, lastDownX, lastDownY, event.getX(), event.getY())) {
                long time = System.currentTimeMillis();
                handlerClick.removeCallbacks(runnableClick);
                if (onDoubleTapListener != null) {
                    if (time - lastClickTime < MAX_DOUBLE_CLICK_TIME) {
                        onDoubleTapListener.onDoubleTap(event.getX(), event.getY());
                        lastClickTime = 0;
                    } else {
                        lastClickTime = System.currentTimeMillis();
                        handlerClick.postDelayed(runnableClick, MAX_CLICK_TIME);
                    }
                } else {
                    handlerClick.postDelayed(runnableClick,0);
                }
            }
            break;

        // TRICKY CASE : FIRST POINTER UP WHEN SECOND STILL DOWN
        case MotionEvent.ACTION_POINTER_1_UP:

            dragLastX = pointer2LastX;
            dragLastY = pointer2LastY;
            state = State.DRAG;
            break;

        // TRICKY CASE : FIRST POINTER UP THEN DOWN WHILE SECOND POINTER STILL UP
        case MotionEvent.ACTION_POINTER_1_DOWN:
            pointer2LastX = event.getX(POINTER1);
            pointer2LastY = event.getY(POINTER1);

            startDrag(event);
            startZoom(event);
            state = State.ZOOM;
            break;

        // NORMAL CASE : MOVE
        case MotionEvent.ACTION_MOVE:

            switch (state) {
                case ZOOM:
                    pointer2LastX = event.getX(POINTER2);
                    pointer2LastY = event.getY(POINTER2);
                    zoom(event);

                case DRAG:
                    drag(event);
                    break;
                default:
                    break;
            }
            break;
    }

    return true;
}
 
Example 7
Source File: RotateGestureDetector.java    From GestureTransformableView with MIT License 4 votes vote down vote up
@SuppressWarnings("deprecation")
synchronized public boolean onTouchEvent(MotionEvent event) {

    float eventX = event.getX();
    float eventY = event.getY();
    int count = event.getPointerCount();

    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:
        downX = eventX;
        downY = eventY;
        if (count >= 2) {
            downX2 = event.getX(1);
            downY2 = event.getY(1);
        }
        break;
    case MotionEvent.ACTION_POINTER_DOWN:
        downX2 = event.getX(1);
        downY2 = event.getY(1);
        break;
    case MotionEvent.ACTION_MOVE:

        if (count >= 2) {

            // 回転角度の取得
            float angle = getAngle(downX, downY, downX2, downY2, eventX, eventY, event.getX(1), event.getY(1));

            // 画像の回転
            if (angle != SLOPE_0) {
                this.angle -= angle * 180d / Math.PI;
            }

            downX2 = event.getX(1);
            downY2 = event.getY(1);

            if (rotationGestureListener != null) {
                rotationGestureListener.onRotation(this);
            }
        }

        break;
    case MotionEvent.ACTION_POINTER_UP:
        switch (event.getAction()) {
        case MotionEvent.ACTION_POINTER_1_UP:
            isFirstPointerUp = true;
            break;
        default:
        }
        break;
    default:
    }

    if (isFirstPointerUp) {
        downX = downX2;
        downY = downY2;
        isFirstPointerUp = false;
    } else {
        downX = eventX;
        downY = eventY;
    }

    return true;
}