Пример #1
0
        public bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
        {
            float dx = e2.GetX() - e1.GetX();
            float dy = e2.GetY() - e1.GetY();

            if (Math.Abs((int) dx) <= MINIMUM_MOVEMENT_DISTANCE &&
                Math.Abs((int) dy) <= MINIMUM_MOVEMENT_DISTANCE)
                return false;

            Command cmd = null;

            if (Math.Abs (dx) > Math.Abs (dy))
            {
                if (dx > 0)
                    cmd = new SwipeRightCommand ();
                else
                    cmd = new SwipeLeftCommand ();
            }
            else
            {
                if (dy > 0)
                    cmd = new SwipeDownCommand ();
                else
                    cmd = new SwipeUpCommand ();
            }

            if (cmd != null)
                Easter.AddCommand (cmd);

            return false;
        }
        public bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
        {
            float dx = e2.GetX() - e1.GetX();
            float dy = e2.GetY() - e1.GetY();

            if (Math.Abs((int)dx) <= MINIMUM_MOVEMENT_DISTANCE &&
                Math.Abs((int)dy) <= MINIMUM_MOVEMENT_DISTANCE)
            {
                return(false);
            }

            Command cmd = null;

            if (Math.Abs(dx) > Math.Abs(dy))
            {
                if (dx > 0)
                {
                    cmd = new SwipeRightCommand();
                }
                else
                {
                    cmd = new SwipeLeftCommand();
                }
            }
            else
            {
                if (dy > 0)
                {
                    cmd = new SwipeDownCommand();
                }
                else
                {
                    cmd = new SwipeUpCommand();
                }
            }

            if (cmd != null)
            {
                Easter.AddCommand(cmd);
            }

            return(false);
        }