com.facebook.react.uimanager.events.NativeGestureUtil Java Examples

The following examples show how to use com.facebook.react.uimanager.events.NativeGestureUtil. 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: ReactDrawerLayout.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
  try {
    if (super.onInterceptTouchEvent(ev)) {
      NativeGestureUtil.notifyNativeGestureStarted(this, ev);
      return true;
    }
  } catch (IllegalArgumentException e) {
    // Log and ignore the error. This seems to be a bug in the android SDK and
    // this is the commonly accepted workaround.
    // https://tinyurl.com/mw6qkod (Stack Overflow)
    Log.w(ReactConstants.TAG, "Error intercepting touch event.", e);
  }

  return false;
}
 
Example #2
Source File: ReactSwipeRefreshLayout.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
  if (shouldInterceptTouchEvent(ev) && super.onInterceptTouchEvent(ev)) {
    NativeGestureUtil.notifyNativeGestureStarted(this, ev);

    // If the pull-to-refresh gesture is interrupted by a parent with its own
    // onInterceptTouchEvent then the refresh indicator gets stuck on-screen
    // so we ask the parent to not intercept this touch event after it started
    if (getParent() != null) {
      getParent().requestDisallowInterceptTouchEvent(true);
    }

    return true;
  }
  return false;
}
 
Example #3
Source File: ReactViewPager.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
  if (!mScrollEnabled) {
    return false;
  }

  try {
    if (super.onInterceptTouchEvent(ev)) {
      NativeGestureUtil.notifyNativeGestureStarted(this, ev);
      return true;
    }
  } catch (IllegalArgumentException e) {
    // Log and ignore the error. This seems to be a bug in the android SDK and
    // this is the commonly accepted workaround.
    // https://tinyurl.com/mw6qkod (Stack Overflow)
    Log.w(ReactConstants.TAG, "Error intercepting touch event.", e);
  }

  return false;
}
 
Example #4
Source File: ReactScrollView.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
  if (!mScrollEnabled) {
    return false;
  }

  try {
    if (super.onInterceptTouchEvent(ev)) {
      NativeGestureUtil.notifyNativeGestureStarted(this, ev);
      ReactScrollViewHelper.emitScrollBeginDragEvent(this);
      mDragging = true;
      enableFpsListener();
      return true;
    }
  } catch (IllegalArgumentException e) {
    // Log and ignore the error. This seems to be a bug in the android SDK and
    // this is the commonly accepted workaround.
    // https://tinyurl.com/mw6qkod (Stack Overflow)
    Log.w(ReactConstants.TAG, "Error intercepting touch event.", e);
  }

  return false;
}
 
Example #5
Source File: ReactHorizontalScrollView.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
  if (!mScrollEnabled) {
    return false;
  }

  try {
    if (super.onInterceptTouchEvent(ev)) {
      NativeGestureUtil.notifyNativeGestureStarted(this, ev);
      ReactScrollViewHelper.emitScrollBeginDragEvent(this);
      mDragging = true;
      enableFpsListener();
      return true;
    }
  } catch (IllegalArgumentException e) {
    // Log and ignore the error. This seems to be a bug in the android SDK and
    // this is the commonly accepted workaround.
    // https://tinyurl.com/mw6qkod (Stack Overflow)
    Log.w(ReactConstants.TAG, "Error intercepting touch event.", e);
  }

  return false;
}
 
Example #6
Source File: DirectedScrollView.java    From react-native-directed-scrollview with MIT License 6 votes vote down vote up
private void onActionMove(MotionEvent motionEvent) {
  NativeGestureUtil.notifyNativeGestureStarted(this, motionEvent);

  if (isScaleInProgress) return;

  isScrollInProgress = true;

  float deltaX = motionEvent.getX() - startTouchX;
  float deltaY = motionEvent.getY() - startTouchY;

  scrollX = startScrollX + deltaX;
  scrollY = startScrollY + deltaY;

  if (bounces) {
    clampAndTranslateChildren(false, getMaxScrollY() <= 0 && !alwaysBounceVertical, getMaxScrollX() <= 0 && !alwaysBounceHorizontal);
  } else {
    clampAndTranslateChildren(false);
  }

  this.emitScrollEvent(ScrollEventType.SCROLL, deltaX * -1, deltaY * -1);
}
 
Example #7
Source File: ReactViewPager.java    From react-native-image-zoom with MIT License 6 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (!mScrollEnabled) {
        return false;
    }
    try {
        if (super.onInterceptTouchEvent(ev)) {
            NativeGestureUtil.notifyNativeGestureStarted(this, ev);
            return true;
        }
        return false;
    }
    catch (Exception e) {
        return false;
    }
}
 
Example #8
Source File: ReactSmartRefreshLayout.java    From react-native-SmartRefreshLayout with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (shouldInterceptTouchEvent(ev) && super.onInterceptTouchEvent(ev)) {
        NativeGestureUtil.notifyNativeGestureStarted(this, ev);
        return true;
    }
    return false;
}
 
Example #9
Source File: ReactViewPager.java    From react-native-tabbed-view-pager-android with MIT License 5 votes vote down vote up
@Override public boolean onInterceptTouchEvent(MotionEvent ev) {
  if (!mScrollEnabled) {
    return false;
  }

  if (super.onInterceptTouchEvent(ev)) {
    NativeGestureUtil.notifyNativeGestureStarted(this, ev);
    return true;
  }
  return false;
}