Esempio n. 1
0
        public override bool OnInterceptTouchEvent(MotionEvent ev)
        {
            var action = ev.Action;

            if (action == MotionEventActions.Cancel || action == MotionEventActions.Up)
            {
                mDragHelper.Cancel();
                return(false);
            }
            return(mDragHelper.ShouldInterceptTouchEvent(ev));
        }
Esempio n. 2
0
 /// <summary>
 /// Intercepts only touch events over the draggable view.
 /// </summary>
 /// <param name="ev"></param>
 /// <returns></returns>
 public override bool OnInterceptTouchEvent(MotionEvent ev)
 {
     try
     {
         bool handled = false;
         if (Enabled)
         {
             handled = DragHelper.ShouldInterceptTouchEvent(ev) &&
                       DragHelper.IsViewUnder(DraggableView, (int)ev.GetX(), (int)ev.GetY());
         }
         else
         {
             DragHelper.Cancel();
         }
         return(handled || base.OnInterceptTouchEvent(ev));
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
         return(base.OnInterceptTouchEvent(ev));
     }
 }
Esempio n. 3
0
        public override bool OnInterceptTouchEvent(MotionEvent ev)
        {
            var action = MotionEventCompat.GetActionMasked(ev);

            if (!_canSlide || !SlidingEnabled || (_isUnableToDrag && action != (int)MotionEventActions.Down))
            {
                _dragHelper.Cancel();
                return(base.OnInterceptTouchEvent(ev));
            }

            if (action == (int)MotionEventActions.Cancel || action == (int)MotionEventActions.Up)
            {
                _dragHelper.Cancel();
                return(false);
            }

            var x            = ev.GetX();
            var y            = ev.GetY();
            var interceptTap = false;

            switch (action)
            {
            case (int)MotionEventActions.Down:
                _isUnableToDrag = false;
                _initialMotionX = x;
                _initialMotionY = y;
                if (IsDragViewUnder((int)x, (int)y) && !IsUsingDragViewTouchEvents)
                {
                    interceptTap = true;
                }
                break;

            case (int)MotionEventActions.Move:
                var adx      = Math.Abs(x - _initialMotionX);
                var ady      = Math.Abs(y - _initialMotionY);
                var dragSlop = _dragHelper.TouchSlop;

                if (IsUsingDragViewTouchEvents)
                {
                    if (adx > _scrollTouchSlop && ady < _scrollTouchSlop)
                    {
                        return(base.OnInterceptTouchEvent(ev));
                    }
                    if (ady > _scrollTouchSlop)
                    {
                        interceptTap = IsDragViewUnder((int)x, (int)y);
                    }
                }

                if ((ady > dragSlop && adx > ady) || !IsDragViewUnder((int)x, (int)y))
                {
                    _dragHelper.Cancel();
                    _isUnableToDrag = true;
                    return(false);
                }
                break;
            }

            var interceptForDrag = _dragHelper.ShouldInterceptTouchEvent(ev);

            return(interceptForDrag || interceptTap);
        }