Beispiel #1
0
 private void hideLoading() {
   ViewAnimator viewAnimator = (ViewAnimator) findViewById(R.id.viewAnimator);
   viewAnimator.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left));
   viewAnimator.setOutAnimation(
       AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right));
   viewAnimator.showNext();
 }
  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();
  }
  // Some tests with viewFlipper in order to switch between Smart List and Full List
  // TODO: Remove this code and upgrade to something similar to Launcher. Drag and slide views by
  // using gestures.
  @Override
  public boolean onTouch(View v, MotionEvent event) {
    // Get the action that was done on this touch event
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        {
          // store the X value when the user's finger was pressed down
          downXvalue = event.getX();
          break;
        }

      case MotionEvent.ACTION_UP:
        {
          // Get the X value when the user released his/her finger
          float currentX = event.getX();

          // going backwards: pushing stuff to the right
          if (downXvalue < currentX) {
            // Get a reference to the ViewFlipper
            // ViewFlipper vf = (ViewFlipper) findViewById(R.id.viewFlipper_Lists_Container);
            // Set the animation
            v.setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_left));
            // Flip!
            ((ViewAnimator) v).showPrevious();
          }

          // going forwards: pushing stuff to the left
          if (downXvalue > currentX) {
            // Get a reference to the ViewFlipper
            // ViewFlipper vf = (ViewFlipper) findViewById(R.id.viewFlipper_Lists_Container);
            // Set the animation
            v.setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_right));
            // Flip!
            ((ViewAnimator) v).showNext();
          }
          break;
        }
    }
    // if you return false, these actions will not be recorded
    return true;
  }
Beispiel #4
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();
  }