Cheesebaron.SlidingUpPanel.SlidingUpPanelLayout.OnTouchEvent C# (CSharp) 메소드

OnTouchEvent() 공개 메소드

public OnTouchEvent ( Android.Views.MotionEvent ev ) : bool
ev Android.Views.MotionEvent
리턴 bool
        public override bool OnTouchEvent(MotionEvent ev)
        {
            if (!_canSlide || !SlidingEnabled)
                return base.OnTouchEvent(ev);

            _dragHelper.ProcessTouchEvent(ev);
            var action = (int)ev.Action;

            switch (action & MotionEventCompat.ActionMask)
            {
                case (int)MotionEventActions.Down:
                {
                    var x = ev.GetX();
                    var y = ev.GetY();
                    _initialMotionX = x;
                    _initialMotionY = y;
                    break;
                }
                case (int)MotionEventActions.Up:
                {
                    var x = ev.GetX();
                    var y = ev.GetY();
                    var dx = x - _initialMotionX;
                    var dy = y - _initialMotionY;
                    var slop = _dragHelper.TouchSlop;
                    var dragView = _dragView ?? _slideableView;
                    if (dx * dx + dy * dy < slop * slop && IsDragViewUnder((int)x, (int)y))
                    {
                        dragView.PlaySoundEffect(SoundEffects.Click);
                        if (!IsExpanded && !IsAnchored)
                            ExpandPane(_anchorPoint);
                        else
                            CollapsePane();
                    }
                    break;
                }
            }

            return true;
        }