public bool OnTouch(View v, MotionEvent e) { if (_gestureDetector.OnTouchEvent(e)) { return(true); } var returnValue = _gestureDetector.OnTouchEvent(e); var x = (int)e.RawX; switch (e.Action) { case MotionEventActions.Move: if (_start) { _prevScrollX = x; _start = false; } break; case MotionEventActions.Up: _start = true; _currentScrollX = x; int minFactor = _itemWidth / SwipePageOnFactor; if ((_prevScrollX - _currentScrollX) > minFactor) { if (_activeItem < _maxItem - 1) { _activeItem = _activeItem + 1; } } else if ((_currentScrollX - _prevScrollX) > minFactor) { if (_activeItem > 0) { _activeItem = _activeItem - 1; } } //_scrollTo = _activeItem * _itemWidth; //SmoothScrollTo(_scrollTo, 0); if (_activeItem != _prevActiveItem) { SetCenter(_activeItem); ItemSelectedChangeEventHandlerArgs args = new ItemSelectedChangeEventHandlerArgs { itemSelected = _activeItem }; OnItemSelectedChangeEventHandler(args); } returnValue = true; break; } return(returnValue); }
protected virtual void OnItemSelectedChangeEventHandler(ItemSelectedChangeEventHandlerArgs e) { EventHandler <ItemSelectedChangeEventHandlerArgs> handler = ItemSelectedChangeEventHandler; if (handler != null) { handler(this, e); } }