public override bool OnInterceptTouchEvent(CoordinatorLayout parent, Object child, MotionEvent ev) { if (parent.IsPointInChildBounds(child as SnackbarLayout, (int) ev.GetX(), (int) ev.GetY())) { switch (ev.ActionMasked) { case MotionEventActions.Down: SnackbarManager.Instance().CancelTimeout(TSnackbar.getInstace().mManagerCallback); break; case MotionEventActions.Up: case MotionEventActions.Cancel: SnackbarManager.Instance().RestoreTimeout(TSnackbar.getInstace().mManagerCallback); break; } } return base.OnInterceptTouchEvent(parent, child, ev); }
public override bool OnInterceptTouchEvent( CoordinatorLayout parent, Java.Lang.Object childObject, MotionEvent @event) { View child = Android.Runtime.Extensions.JavaCast <View>(childObject); if (!child.IsShown) { Debug.WriteLineIf(DebugTrace, $"OnInterceptTouchEvent: return false"); return(false); } int action = MotionEventCompat.GetActionMasked(@event); // Record the velocity if (action == (int)MotionEventActions.Down) { reset(); } if (mVelocityTracker == null || mVelocityTracker.Handle == IntPtr.Zero) { mVelocityTracker = VelocityTracker.Obtain(); } mVelocityTracker.AddMovement(@event); switch (action) { case (int)MotionEventActions.Up: case (int)MotionEventActions.Cancel: mTouchingScrollingChild = false; mActivePointerId = MotionEvent.InvalidPointerId; // Reset the ignore flag if (mIgnoreEvents) { mIgnoreEvents = false; return(false); } break; case (int)MotionEventActions.Down: int initialX = (int)@event.GetX(); mInitialY = (int)@event.GetY(); View nestedScroll; if (mNestedScrollingChildRef.TryGetTarget(out nestedScroll) && parent.IsPointInChildBounds(nestedScroll, initialX, mInitialY)) { mActivePointerId = @event.GetPointerId(@event.ActionIndex); //mTouchingScrollingChild = true; } mIgnoreEvents = mActivePointerId == MotionEvent.InvalidPointerId && !parent.IsPointInChildBounds(child, initialX, mInitialY); break; } if (!mIgnoreEvents && mViewDragHelper.ShouldInterceptTouchEvent(@event)) { Debug.WriteLineIf(DebugTrace, $"OnInterceptTouchEvent: return true"); return(true); } // We have to handle cases that the ViewDragHelper does not capture the bottom sheet because // it is not the top most view of its parent. This is not necessary when the touch event is // happening over the scrolling content as nested scrolling logic handles that case. View scroll; var result = action == (int)MotionEventActions.Move && mNestedScrollingChildRef.TryGetTarget(out scroll) && !mIgnoreEvents && mState != STATE_DRAGGING && !parent.IsPointInChildBounds(scroll, (int)@event.GetX(), (int)@event.GetY()) && Math.Abs(mInitialY - @event.GetY()) > mViewDragHelper.TouchSlop; Debug.WriteLineIf(DebugTrace, $"OnInterceptTouchEvent: return {result}"); return(result); }
public override bool OnInterceptTouchEvent(CoordinatorLayout parent, Java.Lang.Object cChild, MotionEvent ev) { var child = cChild.JavaCast <View>(); if (!child.IsShown) { _ignoreEvents = true; return(false); } var action = ev.ActionMasked; if (action == MotionEventActions.Down) { Reset(); } switch (action) { case MotionEventActions.Up: case MotionEventActions.Cancel: _touchingScrollingChild = false; _activePointerId = MotionEvent.InvalidPointerId; // Reset the ignore flag if (_ignoreEvents) { _ignoreEvents = false; return(false); } break; case MotionEventActions.Down: _scrollVelocityTracker.Clear(); int initialX = (int)ev.GetX(); _initialY = (int)ev.GetY(); if (_state == StateAnchorPoint) { _activePointerId = ev.GetPointerId(ev.ActionIndex); _touchingScrollingChild = true; } else { _nestedScrollingChildRef.TryGetTarget(out View scroll); if (scroll != null && parent.IsPointInChildBounds(scroll, initialX, _initialY)) { _activePointerId = ev.GetPointerId(ev.ActionIndex); _touchingScrollingChild = true; } } _ignoreEvents = _activePointerId == MotionEvent.InvalidPointerId && !parent.IsPointInChildBounds(child, initialX, _initialY); break; case MotionEventActions.Move: break; } if (!_ignoreEvents && _viewDragHelper.ShouldInterceptTouchEvent(ev)) { return(true); } // We have to handle cases that the ViewDragHelper does not capture the bottom sheet because // it is not the top most view of its parent. This is not necessary when the touch event is // happening over the scrolling content as nested scrolling logic handles that case. _nestedScrollingChildRef.TryGetTarget(out View scroll1); return(action == MotionEventActions.Move && scroll1 != null && !_ignoreEvents && _state != StateDragging && !parent.IsPointInChildBounds(scroll1, (int)ev.GetX(), (int)ev.GetY()) && System.Math.Abs(_initialY - ev.GetY()) > _viewDragHelper.TouchSlop); }