예제 #1
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
   */
  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, dir, duration);

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

    viewAnimator.setDisplayedChild(nextIndex);
  }
  private void show(int which) {
    if ((which < 0) || (which >= mViewAnimator.getChildCount())) {
      LogUtils.log(this, Log.WARN, "Tried to show a module with an index out of bounds.");
      return;
    }

    if (which != mViewAnimator.getDisplayedChild()) {
      // Interrupt speech and stop the previous module.
      mAccessibilityManager.interrupt();
      interrupt();
      stopRepeating();
      mViewAnimator.setOnKeyListener(null);
      getCurrentModule().onPause();
      getCurrentModule().onStop();
    }

    mViewAnimator.setDisplayedChild(which);
  }
  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();
  }