Ejemplo n.º 1
0
 public bool onUp(MotionEvent e)
 {
     //System.Diagnostics.Debug.WriteLine("DownUpGestureListener." + P42.Utils.ReflectionExtensions.CallerMemberName(), " e:" + e);
     //System.Console.WriteLine ("onUP: " + e);
     //bool result = false;
     foreach (var listener in _listeners)
     {
         if (listener.HandlesUp)
         {
             int[] viewLocation = { 0, 0 };
             _view?.GetLocationInWindow(viewLocation);
             DownUpEventArgs args = new AndroidDownUpEventArgs(e, _view, viewLocation);
             args.Listener = listener;
             listener.OnUp(args);
             if (args.Handled)
             {
                 break;
             }
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        public override bool OnDown(MotionEvent e)
        {
            //if (_debugEvents) System.Diagnostics.Debug.WriteLine ("OnDown [{0}]",_id);
            //System.Diagnostics.Debug.WriteLine("NativeGestureListener." + P42.Utils.ReflectionExtensions.CallerMemberName() + " Index:" + e);

            if (e.Action != MotionEventActions.Down)
            {
                return(false);
            }

            _onDownDateTime = DateTime.Now;
            Start           = e;
            _panning        = false;
            _pinching       = false;
            _rotating       = false;
            _multiMoving    = false;
            TappedTimerStop();
            LongPressTimerStart();
            bool handled = false;

            foreach (var listener in _listeners)
            {
                if (listener.HandlesDown)
                {
                    var _view = (Android.Views.View)_weakReferenceView?.Get();
                    _view?.GetLocationInWindow(_viewLocationAtOnDown);
                    var args = new AndroidDownUpEventArgs(e, _view, _viewLocationAtOnDown);
                    args.Listener = listener;
                    listener.OnDown(args);
                    handled |= args.Handled;
                    //if (args.Handled)
                    //	return true;
                }
            }
            //return handled; // we are going to (in NativeGestureDetector) always capture a DOWN touch event so we can receive all updates to this gesture
            return(true);
        }
Ejemplo n.º 3
0
        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);
        }