public override bool OnInterceptTouchEvent(MotionEvent ev)
        {
            if (ev.Action != MotionEventActions.Down && mTouchView == null)
            {
                return base.OnInterceptTouchEvent(ev);
            }

            int action = (int)ev.Action;
            switch (action & MotionEventCompat.ActionMask)
            {
                case (int)MotionEventActions.Down:
                    dx = 0.0f; // reset
                    dy = 0.0f; // reset
                    startClickTime = Java.Lang.JavaSystem.CurrentTimeMillis(); // reset
                    int oldPos = mTouchPosition;
                    mDownX = ev.GetX();
                    mDownY = ev.GetY();
                    mTouchState = TOUCH_STATE_NONE;
                    mTouchPosition = GetChildAdapterPosition(FindChildViewUnder((int)ev.GetX(), (int)ev.GetY()));
                    if (mTouchPosition == oldPos && mTouchView != null
                            && mTouchView.IsOpen())
                    {
                        mTouchState = TOUCH_STATE_X;
                        mTouchView.OnSwipe(ev);
                    }
                    // find the touched child view
                    View view = null;
                    ViewHolder vh = FindViewHolderForAdapterPosition(mTouchPosition);
                    if (vh != null)
                    {
                        view = vh.ItemView;
                    }
                    // is not touched the opened menu view, so we intercept this touch event
                    if (mTouchPosition != oldPos && mTouchView != null && mTouchView.IsOpen())
                    {
                        mTouchView.SmoothCloseMenu();
                        mTouchView = null;
                        // try to cancel the touch event
                        MotionEvent cancelEvent = MotionEvent.Obtain(ev);
                        cancelEvent.Action = MotionEventActions.Cancel;
                        base.OnTouchEvent(cancelEvent);
                        return true;
                    }
                    if (view is SwipeMenuLayout)
                    {
                        mTouchView = (SwipeMenuLayout)view;
                        mTouchView.SetSwipeDirection(mDirection);
                    }
                    if (mTouchView != null)
                    {
                        mTouchView.OnSwipe(ev);
                    }
                    break;
                case (int)MotionEventActions.Move:
                    dy = Math.Abs((ev.GetY() - mDownY));
                    dx = Math.Abs((ev.GetX() - mDownX));
                    if (mTouchState == TOUCH_STATE_X && mTouchView.IsSwipeEnable())
                    {
                        mTouchView.OnSwipe(ev);
                        ev.Action = MotionEventActions.Cancel;
                        base.OnTouchEvent(ev);
                    }
                    else if (mTouchState == TOUCH_STATE_NONE && mTouchView.IsSwipeEnable())
                    {
                        if (Math.Abs(dy) > mViewConfiguration.ScaledTouchSlop)
                        {
                            mTouchState = TOUCH_STATE_Y;
                        }
                        else if (dx > mViewConfiguration.ScaledTouchSlop)
                        {
                            mTouchState = TOUCH_STATE_X;
                            if (mOnSwipeListener != null)
                            {
                                mOnSwipeListener.onSwipeStart(mTouchPosition);
                            }
                        }
                    }
                    break;
                case (int)MotionEventActions.Up:
                    Boolean isCloseOnUpEvent = false;
                    if (mTouchState == TOUCH_STATE_X && mTouchView.IsSwipeEnable())
                    {
                        isCloseOnUpEvent = !mTouchView.OnSwipe(ev);
                        if (mOnSwipeListener != null)
                        {
                            mOnSwipeListener.onSwipeEnd(mTouchPosition);
                        }
                        if (!mTouchView.IsOpen())
                        {
                            mTouchPosition = -1;
                            mTouchView = null;
                        }
                        ev.Action = MotionEventActions.Cancel;
                        base.OnTouchEvent(ev);
                    }
                    long clickDuration = Java.Lang.JavaSystem.CurrentTimeMillis() - startClickTime;
                    Boolean isOutDuration = clickDuration > ViewConfiguration.LongPressTimeout;
                    Boolean isOutX = dx > mViewConfiguration.ScaledTouchSlop;
                    Boolean isOutY = dy > mViewConfiguration.ScaledTouchSlop;
                    // long pressed or scaled touch, we just intercept up touch event
                    if (isOutDuration || isOutX || isOutY)
                    {
                        return true;
                    }
                    else {
                        float eX = ev.GetX();
                        float eY = ev.GetY();
                        View upView = FindChildViewUnder(eX, eY);
                        if (upView is SwipeMenuLayout)
                        {
                            SwipeMenuLayout smView = (SwipeMenuLayout)upView;
                            int x = (int)eX - smView.Left;
                            int y = (int)eY - smView.Top;
                            View menuView = smView.GetMenuView();
                            float translationX = ViewCompat.GetTranslationX(menuView);
                            float translationY = ViewCompat.GetTranslationY(menuView);
                            // intercept the up event when touched on the contentView of the opened SwipeMenuLayout
                            if (!(x >= menuView.Left + translationX &&
                                    x <= menuView.Right + translationX &&
                                    y >= menuView.Top + translationY &&
                                    y <= menuView.Bottom + translationY) &&
                                    isCloseOnUpEvent)
                            {
                                return true;
                            }
                        }
                    }
                    break;
                case (int)MotionEventActions.Cancel:
                    if (mTouchView != null && mTouchView.IsSwipeEnable())
                    {
                        // when event has canceled, we just consider as up event
                        ev.Action = MotionEventActions.Up;
                        mTouchView.OnSwipe(ev);
                    }
                    break;
            }
            return base.OnInterceptTouchEvent(ev);
        }
 public void SmoothOpenMenu(int position)
 {
     View view = mLlm.FindViewByPosition(position);
     if (view is SwipeMenuLayout) {
         mTouchPosition = position;
         // close pre opened swipe menu
         if (mTouchView != null && mTouchView.IsOpen())
         {
             mTouchView.SmoothCloseMenu();
         }
         mTouchView = (SwipeMenuLayout)view;
         mTouchView.SetSwipeDirection(mDirection);
         mTouchView.SmoothOpenMenu();
     }
 }