@Override
  public void onResume() {
    super.onResume();

    // load animations
    mAnimVcardOut = AnimatorInflater.loadAnimator(this, R.animator.fade_out);
    mAnimVerticalLeftIn = AnimatorInflater.loadAnimator(this, R.animator.fade_in);
    mAnimVerticalRightIn = AnimatorInflater.loadAnimator(this, R.animator.fade_in);

    mAnimVcardOut.addListener(new HideAfterAnimatorListener(mContainerVcard));
    mAnimVerticalLeftIn.addListener(new DisplayBeforeAnimatorListener(mVerticalLeft));
    mAnimVerticalRightIn.addListener(new DisplayBeforeAnimatorListener(mVerticalRight));

    if (!mPrefs.getBoolean(Constants.PREF_SIDE_USED, false)) {
      final Animator animatorHintLeft = AnimatorInflater.loadAnimator(this, R.animator.side_hint);
      final Animator animatorHintRight = AnimatorInflater.loadAnimator(this, R.animator.side_hint);

      animatorHintLeft.addListener(new BothEndsAnimatorListener(mHintLeft));
      animatorHintRight.addListener(new BothEndsAnimatorListener(mHintRight));

      animatorHintLeft.setTarget(mHintLeft);
      animatorHintRight.setTarget(mHintRight);

      animatorHintLeft.start();
      animatorHintRight.start();
    }
  }
示例#2
0
    private void createAnimation() {
      Context appContext = AnimationLoading.this;

      if (animation == null) {
        ObjectAnimator anim =
            (ObjectAnimator) AnimatorInflater.loadAnimator(appContext, R.animator.object_animator);
        anim.addUpdateListener(this);
        anim.setTarget(balls.get(0));

        ValueAnimator fader =
            (ValueAnimator) AnimatorInflater.loadAnimator(appContext, R.animator.animator);
        fader.addUpdateListener(
            new ValueAnimator.AnimatorUpdateListener() {
              public void onAnimationUpdate(ValueAnimator animation) {
                balls.get(1).setAlpha((Float) animation.getAnimatedValue());
              }
            });

        AnimatorSet seq =
            (AnimatorSet) AnimatorInflater.loadAnimator(appContext, R.animator.animator_set);
        seq.setTarget(balls.get(2));

        ObjectAnimator colorizer =
            (ObjectAnimator) AnimatorInflater.loadAnimator(appContext, R.animator.color_animator);
        colorizer.setTarget(balls.get(3));

        animation = new AnimatorSet();
        ((AnimatorSet) animation).playTogether(anim, fader, seq, colorizer);
      }
    }