/**
         * The {@code FlipDirection} enumeration defines the most typical flip view transitions: left-to-right and right-to-left. {@code FlipDirection} is used during the creation of {@link FlipAnimation} animations.
         *
         * @author Ephraim A. Tekle
         *
         */
        /**
         * Create a pair of {@link FlipAnimation} that can be used to flip 3D transition from {@code fromView} to {@code toView}. A typical use case is with {@link ViewAnimator} as an out and in transition.
         *
         * NOTE: Avoid using this method. Instead, use {@link #flipTransition}.
         *
         * @param fromView the view transition away from
         * @param toView the view transition to
         * @param dir the flip direction
         * @param duration the transition duration in milliseconds
         * @param interpolator the interpolator to use (pass {@code null} to use the {@link AccelerateInterpolator} interpolator)
         * @return
         */

        public static Animation[] FlipAnimation(View fromView, View toView, FlipDirection dir, long duration, IInterpolator interpolator)
        {
            Animation[] result = new Animation[2];
            float       centerX;
            float       centerY;

            centerX = fromView.Width / 2.0f;
            centerY = fromView.Height / 2.0f;

            FlipAnimation outFlip = new FlipAnimation(0, dir.EndDegreeForFirstView(), centerX, centerY,
                                                      SpotTiles.FlipAnimation.ScaleDefault, ScaleUpDownEnum.ScaleDown);

            outFlip.Duration     = duration;
            outFlip.FillAfter    = true;
            outFlip.Interpolator = interpolator ?? new AccelerateInterpolator();

            if (dir == FlipDirection.BottomTop || dir == FlipDirection.TopBottom)
            {
                outFlip.Direction = Direction.X;
            }
            else
            {
                outFlip.Direction = Direction.Y;
            }

            AnimationSet outAnimation = new AnimationSet(true);

            outAnimation.AddAnimation(outFlip);
            result[0] = outAnimation;

            // Uncomment the following if toView has its layout established (not the case if using ViewFlipper and on first show)
            //centerX = toView.getWidth() / 2.0f;
            //centerY = toView.getHeight() / 2.0f;

            FlipAnimation inFlip = new FlipAnimation(dir.StartDegreeForSecondView(), 0, centerX, centerY,
                                                     SpotTiles.FlipAnimation.ScaleDefault, ScaleUpDownEnum.ScaleUp);

            inFlip.Duration     = duration;
            inFlip.FillAfter    = true;
            inFlip.StartOffset  = duration;
            inFlip.Interpolator = interpolator ?? new AccelerateInterpolator();


            if (dir == FlipDirection.BottomTop || dir == FlipDirection.TopBottom)
            {
                outFlip.Direction = Direction.X;
            }
            else
            {
                outFlip.Direction = Direction.Y;
            }

            AnimationSet inAnimation = new AnimationSet(true);

            inAnimation.AddAnimation(inFlip);
            result[1] = inAnimation;

            return(result);
        }
        /**
         * The {@code FlipDirection} enumeration defines the most typical flip view transitions: left-to-right and right-to-left. {@code FlipDirection} is used during the creation of {@link FlipAnimation} animations.
         * 
         * @author Ephraim A. Tekle
         *
         */
        /**
	 * Create a pair of {@link FlipAnimation} that can be used to flip 3D transition from {@code fromView} to {@code toView}. A typical use case is with {@link ViewAnimator} as an out and in transition.
	 * 
	 * NOTE: Avoid using this method. Instead, use {@link #flipTransition}.
	 *  
	 * @param fromView the view transition away from
	 * @param toView the view transition to
	 * @param dir the flip direction
	 * @param duration the transition duration in milliseconds
	 * @param interpolator the interpolator to use (pass {@code null} to use the {@link AccelerateInterpolator} interpolator) 
	 * @return
	 */

        public static Animation[] FlipAnimation(View fromView, View toView, FlipDirection dir, long duration, IInterpolator interpolator)
        {
            Animation[] result = new Animation[2];
            float centerX;
            float centerY;

            centerX = fromView.Width/2.0f;
            centerY = fromView.Height/2.0f;

            FlipAnimation outFlip = new FlipAnimation(0, dir.EndDegreeForFirstView(), centerX, centerY,
                SpotTiles.FlipAnimation.ScaleDefault, ScaleUpDownEnum.ScaleDown);
            outFlip.Duration = duration;
            outFlip.FillAfter = true;
            outFlip.Interpolator = interpolator ?? new AccelerateInterpolator();

            if (dir == FlipDirection.BottomTop || dir == FlipDirection.TopBottom)
                outFlip.Direction = Direction.X;
            else
                outFlip.Direction = Direction.Y;

            AnimationSet outAnimation = new AnimationSet(true);
            outAnimation.AddAnimation(outFlip);
            result[0] = outAnimation;

            // Uncomment the following if toView has its layout established (not the case if using ViewFlipper and on first show)
            //centerX = toView.getWidth() / 2.0f;
            //centerY = toView.getHeight() / 2.0f; 

            FlipAnimation inFlip = new FlipAnimation(dir.StartDegreeForSecondView(), 0, centerX, centerY,
                SpotTiles.FlipAnimation.ScaleDefault, ScaleUpDownEnum.ScaleUp);
            inFlip.Duration = duration;
            inFlip.FillAfter = true;
            inFlip.StartOffset = duration;
            inFlip.Interpolator = interpolator ?? new AccelerateInterpolator();


            if (dir == FlipDirection.BottomTop || dir == FlipDirection.TopBottom)
                outFlip.Direction = Direction.X;
            else
                outFlip.Direction = Direction.Y;

            AnimationSet inAnimation = new AnimationSet(true);
            inAnimation.AddAnimation(inFlip);
            result[1] = inAnimation;

            return result;

        }