private int getPressedPointerIndex(MotionEvent event, int i) {
    final int count = event.getPointerCount();
    final int action = event.getActionMasked();
    final int index = event.getActionIndex();
    if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
      if (i >= index) {
        i++;
      }
    }
    return (i < count) ? i : -1;
  }
Gets the index of the i-th pressed pointer. Normally, the index will be equal to i, except in
the case when the pointer is released.

@return index of the specified pointer or -1 if not found (i.e. not enough pointers are down)
samples/gestures/src/main/java/com/facebook/samples/gestures/MultiPointerGestureDetector.java