public void flipTransition(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);
    Animation[] animc = AnimationFactory.flipAnimation(fromView, toView, dir, 500, null);

    animc[0].setAnimationListener(this);

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

    viewAnimator.showNext();
  }
Ejemplo n.º 2
0
  /**
   * 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
   * @param duration the transition duration in milliseconds
   */
  public static void flipTransition(
      final ViewAnimator viewAnimator, FlipDirection dir, long duration) {

    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),
            duration,
            null);

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

    viewAnimator.showNext();
  }
Ejemplo n.º 3
0
 public void showBack() {
   AnimationFactory.flipTransition(mViewAnimator, FlipDirection.LEFT_RIGHT);
   isShowingBack = true;
 }
Ejemplo n.º 4
0
 public void showFront() {
   if (isShowingBack) {
     AnimationFactory.flipTransition(mViewAnimator, FlipDirection.LEFT_RIGHT);
   }
   isShowingBack = false;
 }