void OnLongPressTimerElapsed(object sender, ElapsedEventArgs e) { LongPressingTimerStop(); if (!_panning && !_longPressed && !_pinching && !_rotating) { _longPressed = true; Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { var _view = (Android.Views.View)_weakReferenceView?.Get(); if (_view == null || _listeners == null || !_listeners.Any()) { return; } foreach (var listener in _listeners) { if (listener.HandlesLongPressing) { var args = new AndroidLongPressEventArgs(Start, null, _view, _viewLocationAtOnDown); args.Listener = listener; listener.OnLongPressing(args); //if (args.Handled) // break; } } }); } }
public bool OnUp(MotionEvent ev) { //System.Diagnostics.Debug.WriteLine("NativeGestureListener." + P42.Utils.ReflectionExtensions.CallerMemberName() + " action:" + ev.Action + " index" + ev.ActionIndex + " e:" + ev); if (ev.Action != MotionEventActions.Up) { return(false); } var touchDuration = DateTime.Now - _onDownDateTime; _numberOfTaps++; LongPressingTimerStop(); TappedTimerStart(ev, _numberOfTaps); var _view = (Android.Views.View)_weakReferenceView?.Get(); if (_view == null || _listeners == null || !_listeners.Any()) { return(false); } bool handled = false; foreach (var listener in _listeners) { if (listener.HandlesUp) { DownUpEventArgs args = new AndroidDownUpEventArgs(ev, _view, _viewLocationAtOnDown); args.Listener = listener; listener.OnUp(args); handled |= args.Handled; //if (args.Handled) // break; } } if (_panning) { _numberOfTaps = 0; foreach (var listener in _listeners) { if (listener.HandlesPanned) { PanEventArgs args = new AndroidPanEventArgs(LastPan ?? Start, ev, LastPanArgs, _view, _viewLocationAtOnDown); args.Listener = listener; listener.OnPanned(args); handled |= args.Handled; //if (args.Handled) // break; } } } else if (_longPressed) { foreach (var listener in _listeners) { if (listener.HandlesLongPressed) { LongPressEventArgs args = new AndroidLongPressEventArgs(Start, ev, _view, _viewLocationAtOnDown); args.Listener = listener; listener.OnLongPressed(args); handled |= args.Handled; //if (args.Handled) // break; } } } else if (!_pinching && !_rotating) { foreach (var listener in _listeners) { if (listener.HandlesTapping) { TapEventArgs args = new AndroidTapEventArgs(ev, _view, _numberOfTaps, _viewLocationAtOnDown); args.Listener = listener; listener.OnTapping(args); handled |= args.Handled; //if (args.Handled) // break; } } if (_numberOfTaps % 2 == 0) { foreach (var listener in _listeners) { if (listener.HandlesDoubleTapped) { TapEventArgs args = new AndroidTapEventArgs(ev, _view, _numberOfTaps, _viewLocationAtOnDown); args.Listener = listener; listener.OnDoubleTapped(args); handled |= args.Handled; //if (args.Handled) // break; } } } } LastPanArgs = null; LastPan = null; return(handled); }