/** * When the user swipes their finger horizontally, dispatch * those touch events to the ViewPager. When they swipe * vertically, dispatch those touch events to the date or * time picker (depending on which page we're currently on). * * @param event */ public override bool DispatchTouchEvent(MotionEvent e) { switch (e.Action) { case MotionEventActions.Down: _x1 = e.GetX(); _y1 = e.GetY(); break; case MotionEventActions.Move: _x2 = e.GetX(); _y2 = e.GetY(); if (isScrollingHorizontal(_x1, _y1, _x2, _y2)) { // When the user is scrolling the ViewPager horizontally, // block the pickers from scrolling vertically. return(base.DispatchTouchEvent(e)); } break; } // As long as the ViewPager isn't scrolling horizontally, // dispatch the event to the DatePicker or TimePicker, // depending on which page the ViewPager is currently on. switch (CurrentItem) { case 0: if (_datePicker != null) { _datePicker.DispatchTouchEvent(e); } break; case 1: if (_timePicker != null) { _timePicker.DispatchTouchEvent(e); } break; } // need this for the ViewPager to scroll horizontally at all return(base.DispatchTouchEvent(e)); }
public override bool DispatchTouchEvent(MotionEvent e) { switch (e.Action) { case MotionEventActions.Down: { x1 = e.RawX; y1 = e.RawY; } break; case MotionEventActions.Move: { x2 = e.RawX; y2 = e.RawY; if (IsScrollingHorizontal(x1, y2, x2, y2)) { return(base.DispatchTouchEvent(e)); } } break; } switch (CurrentItem) { case 0: { if (mDatePicker != null) { mDatePicker.DispatchTouchEvent(e); } } break; case 1: { if (mTimePicker != null) { mTimePicker.DispatchTouchEvent(e); } } break; } return(base.DispatchTouchEvent(e)); }