/**
   * Flip to the next view of the {@code ViewAnimator}'s subviews. A call to this method will
   * initiate a {@link FlipAnimation} to show the next View. If the currently visible view is the
   * last view, flip direction will be reversed for this transition.
   *
   * @param viewAnimator the {@code ViewAnimator}
   * @param dir the direction of flip
   */
  public static void flipTransition(final ViewAnimator viewAnimator, FlipDirection dir) {

    final View fromView = viewAnimator.getCurrentView();
    final int currentIndex = viewAnimator.getDisplayedChild();
    final int nextIndex = (currentIndex + 1) % viewAnimator.getChildCount();

    final View toView = viewAnimator.getChildAt(nextIndex);

    Animation[] animc =
        AnimationFactory.flipAnimation(
            fromView,
            toView,
            (nextIndex < currentIndex ? dir.theOtherDirection() : dir),
            500,
            null);

    viewAnimator.setOutAnimation(animc[0]);
    viewAnimator.setInAnimation(animc[1]);

    viewAnimator.showNext();
  }