Java Code Examples for android.support.v4.view.MotionEventCompat#getPointerCount()

The following examples show how to use android.support.v4.view.MotionEventCompat#getPointerCount() . 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: SlideViewDragHelper.java    From Aurora with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 2
Source File: ViewDragHelper.java    From AndroidSlidingUpPanel with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        // Sometimes we can try and save last motion for a pointer never recorded in initial motion. In this case we just discard it.
        if (mLastMotionX != null && mLastMotionY != null
                && mLastMotionX.length > pointerId && mLastMotionY.length > pointerId) {
            mLastMotionX[pointerId] = x;
            mLastMotionY[pointerId] = y;
        }
    }
}
 
Example 3
Source File: CustomViewDragHelper.java    From DragVideo with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 4
Source File: ViewDragHelper.java    From MyHearts with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 5
Source File: ViewDragHelper.java    From Android-Application-ZJB with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 6
Source File: ViewDragHelper.java    From MicroReader with MIT License 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 7
Source File: ViewDragHelper.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 8
Source File: ViewDragHelper.java    From Cashew with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 9
Source File: ViewDragHelper.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 10
Source File: DidiViewDragHelper.java    From DidiLayout with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        // Sometimes we can try and save last motion for a pointer never recorded in initial motion. In this case we just discard it.
        if (mLastMotionX != null && mLastMotionY != null
                && mLastMotionX.length > pointerId && mLastMotionY.length > pointerId) {
            mLastMotionX[pointerId] = x;
            mLastMotionY[pointerId] = y;
        }
    }
}
 
Example 11
Source File: ViewDragHelper.java    From Aurora with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 12
Source File: ViewDragHelper.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 13
Source File: ViewDragHelper.java    From MaterialQQLite with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 14
Source File: ViewDragHelper.java    From letv with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        int pointerId = MotionEventCompat.getPointerId(ev, i);
        float x = MotionEventCompat.getX(ev, i);
        float y = MotionEventCompat.getY(ev, i);
        this.mLastMotionX[pointerId] = x;
        this.mLastMotionY[pointerId] = y;
    }
}
 
Example 15
Source File: ViewDragHelper.java    From Dragger with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
  final int pointerCount = MotionEventCompat.getPointerCount(ev);
  for (int i = 0; i < pointerCount; i++) {
    final int pointerId = MotionEventCompat.getPointerId(ev, i);
    final float x = MotionEventCompat.getX(ev, i);
    final float y = MotionEventCompat.getY(ev, i);
    mLastMotionX[pointerId] = x;
    mLastMotionY[pointerId] = y;
  }
}
 
Example 16
Source File: ViewDragHelper.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 17
Source File: ViewDragHelper.java    From ChipHellClient with Apache License 2.0 5 votes vote down vote up
private void saveLastMotion(MotionEvent ev) {
    final int pointerCount = MotionEventCompat.getPointerCount(ev);
    for (int i = 0; i < pointerCount; i++) {
        final int pointerId = MotionEventCompat.getPointerId(ev, i);
        final float x = MotionEventCompat.getX(ev, i);
        final float y = MotionEventCompat.getY(ev, i);
        mLastMotionX[pointerId] = x;
        mLastMotionY[pointerId] = y;
    }
}
 
Example 18
Source File: PhotoViewAttacher.java    From AndroidPickPhotoDialog with Apache License 2.0 4 votes vote down vote up
public PhotoViewAttacher(ImageView imageView, boolean zoomable) {
    mImageView = new WeakReference<>(imageView);

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer)
        observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(
            imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getImageView());
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2,
                                       float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
    mBaseRotation = 0.0f;

    // Finally, update the UI so that we're zoomable
    setZoomable(zoomable);
}
 
Example 19
Source File: PhotoViewAttacher.java    From Album with Apache License 2.0 4 votes vote down vote up
public PhotoViewAttacher(ImageView imageView, boolean zoomable) {
    mImageView = new WeakReference<>(imageView);

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer) observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() {

        // forward long click listener
        @Override
        public void onLongPress(MotionEvent e) {
            if (null != mLongClickListener) {
                mLongClickListener.onLongClick(getImageView());
            }
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (mSingleFlingListener != null) {
                if (getScale() > DEFAULT_MIN_SCALE) {
                    return false;
                }

                if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH ||
                    MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                    return false;
                }

                return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
            }
            return false;
        }
    });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
    mBaseRotation = 0.0f;

    // Finally, update the UI so that we're zoomable
    setZoomable(zoomable);
}
 
Example 20
Source File: PhotoViewAttacher.java    From star-zone-android with Apache License 2.0 4 votes vote down vote up
public PhotoViewAttacher(ImageView imageView, boolean zoomable) {
    mImageView = new WeakReference<>(imageView);

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer)
        observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(
            imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
                                           new GestureDetector.SimpleOnGestureListener() {

                                               // forward long click listener
                                               @Override
                                               public void onLongPress(MotionEvent e) {
                                                   if (null != mLongClickListener) {
                                                       mLongClickListener.onLongClick(getImageView());
                                                   }
                                               }

                                               @Override
                                               public boolean onFling(MotionEvent e1, MotionEvent e2,
                                                                      float velocityX, float velocityY) {
                                                   if (mSingleFlingListener != null) {
                                                       if (getScale() > DEFAULT_MIN_SCALE) {
                                                           return false;
                                                       }

                                                       if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                                               || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                                                           return false;
                                                       }

                                                       return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                                                   }
                                                   return false;
                                               }
                                           });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
    mBaseRotation = 0.0f;

    // Finally, update the UI so that we're zoomable
    setZoomable(zoomable);
}