diff --git a/android/src/main/java/com/bottomsheetbehavior/RNBottomSheetBehavior.java b/android/src/main/java/com/bottomsheetbehavior/RNBottomSheetBehavior.java index 1158876..8df7d33 100644 --- a/android/src/main/java/com/bottomsheetbehavior/RNBottomSheetBehavior.java +++ b/android/src/main/java/com/bottomsheetbehavior/RNBottomSheetBehavior.java @@ -189,9 +189,14 @@ public boolean onLayoutChild( CoordinatorLayout parent, V child, int layoutDirec toggleHeaderColor(false); ViewCompat.offsetTopAndBottom(child, mMaxOffset); } + + /** + * Workaround for support SDK 27 race condition + */ if ( mViewDragHelper == null ) { mViewDragHelper = ViewDragHelper.create( parent, mDragCallback ); } + mViewRef = new WeakReference<>(child); mNestedScrollingChildRef = new WeakReference<>( findScrollingChild( child ) ); return true; @@ -219,6 +224,7 @@ public boolean onInterceptTouchEvent( CoordinatorLayout parent, V child, MotionE return false; } break; + case MotionEvent.ACTION_DOWN: int initialX = (int) event.getX(); mInitialY = (int) event.getY(); @@ -235,6 +241,7 @@ public boolean onInterceptTouchEvent( CoordinatorLayout parent, V child, MotionE mIgnoreEvents = mActivePointerId == MotionEvent.INVALID_POINTER_ID && !parent.isPointInChildBounds(child, initialX, mInitialY); break; + case MotionEvent.ACTION_MOVE: break; } @@ -243,7 +250,14 @@ public boolean onInterceptTouchEvent( CoordinatorLayout parent, V child, MotionE // We don't want to trigger a BottomSheet fling as a result of a Cancel MotionEvent (e.g., parent horizontal scroll view taking over touch events) mScrollVelocityTracker.clear(); } - + + /** + * Workaround for Support SDK 27 race condition + */ + if ( mViewDragHelper == null ) { + mViewDragHelper = ViewDragHelper.create( parent, mDragCallback ); + } + if ( ! mIgnoreEvents && mViewDragHelper.shouldInterceptTouchEvent( event ) ) { return true; }