Ejemplo n.º 1
0
 /** Starts the animation. */
 public void start() {
   resetAllPaths();
   animatorSet.cancel();
   animatorSet.setDuration(duration);
   animatorSet.setInterpolator(interpolator);
   animatorSet.setStartDelay(delay);
   animatorSet.start();
 }
 /**
  * Creates a "grow and fade in from the bottom" animation for the specified view.
  *
  * @param view The view to animate
  */
 private static AnimatorSet createGrowFadeInFromBottom(View view) {
   AnimatorSet growFadeInFromBottomAnimation = new AnimatorSet();
   growFadeInFromBottomAnimation.playTogether(
       ObjectAnimator.ofFloat(view, View.SCALE_X, 0.5f, 1).setDuration(125),
       ObjectAnimator.ofFloat(view, View.SCALE_Y, 0.5f, 1).setDuration(125),
       ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1).setDuration(75));
   growFadeInFromBottomAnimation.setStartDelay(50);
   return growFadeInFromBottomAnimation;
 }
 /**
  * Creates a "shrink and fade out from bottom" animation for the specified view.
  *
  * @param view The view to animate
  * @param listener The animation listener
  */
 private static AnimatorSet createShrinkFadeOutFromBottomAnimation(
     View view, Animator.AnimatorListener listener) {
   AnimatorSet shrinkFadeOutFromBottomAnimation = new AnimatorSet();
   shrinkFadeOutFromBottomAnimation.playTogether(
       ObjectAnimator.ofFloat(view, View.SCALE_Y, 1, 0.5f).setDuration(125),
       ObjectAnimator.ofFloat(view, View.ALPHA, 1, 0).setDuration(75));
   shrinkFadeOutFromBottomAnimation.setStartDelay(150);
   shrinkFadeOutFromBottomAnimation.addListener(listener);
   return shrinkFadeOutFromBottomAnimation;
 }
Ejemplo n.º 4
0
  @Override
  public void startAnimation(
      final ViewHolder holder, long duration, final BaseItemAnimator animator) {

    System.out.println("startAnimation");

    float x =
        (holder.itemView.getWidth()
                    - holder.itemView.getPaddingLeft()
                    - holder.itemView.getPaddingRight())
                / 2
            + holder.itemView.getPaddingLeft();
    float y = holder.itemView.getHeight() - holder.itemView.getPaddingBottom();

    AnimatorSet set = new AnimatorSet();

    set.playTogether(
        ObjectAnimator.ofFloat(holder.itemView, "pivotX", x, x, x, x, x),
        ObjectAnimator.ofFloat(holder.itemView, "pivotY", y, y, y, y, y),
        ObjectAnimator.ofFloat(holder.itemView, "rotationX", 90, 55, -30, 15, -15, 0));
    set.addListener(
        new AnimatorListener() {

          @Override
          public void onAnimationStart(Animator animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationRepeat(Animator animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationEnd(Animator animation) {
            animator.dispatchAddFinished(holder);
            animator.mAddAnimations.remove(holder);
            animator.dispatchFinishedWhenDone();
          }

          @Override
          public void onAnimationCancel(Animator animation) {
            // TODO Auto-generated method stub

          }
        });
    set.setStartDelay(mDelay * mDelayCount);
    set.setDuration(animator.getAddDuration());
    set.start();

    animator.mAddAnimations.add(holder);
  }
Ejemplo n.º 5
0
  private void animateLoad() {
    setTranslationY(500);
    setAlpha(0);

    final Animator translateAnimator = ObjectAnimator.ofFloat(this, "translationY", 0);
    translateAnimator.setDuration(400);

    final Animator alphaAnimator = ObjectAnimator.ofFloat(this, "alpha", 1);
    alphaAnimator.setStartDelay(200);
    alphaAnimator.setDuration(600);

    final AnimatorSet set = new AnimatorSet();
    set.playTogether(alphaAnimator, translateAnimator);
    set.setStartDelay(400);

    set.start();
  }
Ejemplo n.º 6
0
  private void startInstallAnimation() {
    mTip1.setAlpha(0);
    mTip2.setAlpha(0);
    mTip3.setAlpha(0);
    mYoutube.setAlpha(0);

    ObjectAnimator anim1 = ObjectAnimator.ofFloat(mTip1, "alpha", 1);
    ObjectAnimator anim2 = ObjectAnimator.ofFloat(mTip2, "alpha", 1);
    ObjectAnimator anim3 = ObjectAnimator.ofFloat(mTip3, "alpha", 1);
    ObjectAnimator anim4 = ObjectAnimator.ofFloat(mYoutube, "alpha", 1);
    AnimatorSet set = new AnimatorSet();
    set.setStartDelay(300);
    set.setDuration(600);
    set.playTogether(anim1, anim2, anim3, anim4);
    set.start();
    mFairyAnimation.start();
  }
Ejemplo n.º 7
0
  private void addTile(int y, int x, int num) {

    Tile tile = new Tile(context);
    tile.setNumber(num);
    tileGrid.addTile(tile, y, x);
    tiles[y][x] = new TileHolder(tile);

    ObjectAnimator scaleYAnimation = ObjectAnimator.ofFloat(tile, "scaleY", 0.8f, 1f);
    ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(tile, "scaleX", 0.8f, 1f);

    AnimatorSet scaleAnimatorSet = new AnimatorSet();
    scaleAnimatorSet.playTogether(scaleXAnimation, scaleYAnimation);
    scaleAnimatorSet.setDuration(100);
    scaleAnimatorSet.setStartDelay(10);
    scaleAnimatorSet.start();

    updateCurrentPostion();
  }
  public void show() {
    if (callback != null) {
      callback.onShowStart();
    }

    ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(this, View.ALPHA, 0f, 1f);

    ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(this, View.SCALE_X, 1.8f, 1f);

    ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(this, View.SCALE_Y, 1.8f, 1f);

    showAnimatorSet = new AnimatorSet();
    showAnimatorSet.playTogether(alphaAnimator, scaleXAnimator, scaleYAnimator);
    showAnimatorSet.setDuration(
        getResources().getInteger(R.integer.framework_animation_duration_long));
    showAnimatorSet.setStartDelay(
        getResources().getInteger(R.integer.framework_animation_delay_short));
    showAnimatorSet.setInterpolator(new Back.EaseOut(2));
    final View container = this;
    showAnimatorSet.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationStart(Animator animation) {
            container.setAlpha(0f);
            container.setVisibility(View.VISIBLE);
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            new Handler()
                .postDelayed(
                    new Runnable() {
                      @Override
                      public void run() {
                        hide();
                      }
                    },
                    getResources().getInteger(R.integer.framework_animation_duration_long));
          }
        });
    showAnimatorSet.start();
  }
  @Override
  public boolean animateChange(
      RecyclerView.ViewHolder oldHolder,
      RecyclerView.ViewHolder newHolder,
      ItemHolderInfo preInfo,
      ItemHolderInfo postInfo) {
    if (preInfo instanceof DesignerNewsItemHolderInfo
        && ((DesignerNewsItemHolderInfo) preInfo).animateAddToPocket) {
      final FeedAdapter.DesignerNewsStoryHolder holder =
          (FeedAdapter.DesignerNewsStoryHolder) newHolder;

      // setup for anim
      holder.itemView.setHasTransientState(true);
      ((ViewGroup) holder.pocket.getParent().getParent()).setClipChildren(false);
      final int initialLeft = holder.pocket.getLeft();
      final int initialTop = holder.pocket.getTop();
      final int translatedLeft = (holder.itemView.getWidth() - holder.pocket.getWidth()) / 2;
      final int translatedTop =
          initialTop - ((holder.itemView.getHeight() - holder.pocket.getHeight()) / 2);
      final ArcMotion arc = new ArcMotion();

      // animate the title & pocket icon up, scale the pocket icon up
      Animator titleMoveFadeOut =
          ObjectAnimator.ofPropertyValuesHolder(
              holder.title,
              PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -(holder.itemView.getHeight() / 5)),
              PropertyValuesHolder.ofFloat(View.ALPHA, 0.54f));

      Animator pocketMoveUp =
          ObjectAnimator.ofFloat(
              holder.pocket,
              View.TRANSLATION_X,
              View.TRANSLATION_Y,
              arc.getPath(initialLeft, initialTop, translatedLeft, translatedTop));
      Animator pocketScaleUp =
          ObjectAnimator.ofPropertyValuesHolder(
              holder.pocket,
              PropertyValuesHolder.ofFloat(View.SCALE_X, 3f),
              PropertyValuesHolder.ofFloat(View.SCALE_Y, 3f));
      ObjectAnimator pocketFadeUp = ObjectAnimator.ofInt(holder.pocket, ViewUtils.IMAGE_ALPHA, 255);

      AnimatorSet up = new AnimatorSet();
      up.playTogether(titleMoveFadeOut, pocketMoveUp, pocketScaleUp, pocketFadeUp);
      up.setDuration(300);
      up.setInterpolator(
          AnimationUtils.loadInterpolator(
              holder.itemView.getContext(), android.R.interpolator.fast_out_slow_in));

      // animate everything back into place
      Animator titleMoveFadeIn =
          ObjectAnimator.ofPropertyValuesHolder(
              holder.title,
              PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0f),
              PropertyValuesHolder.ofFloat(View.ALPHA, 1f));
      Animator pocketMoveDown =
          ObjectAnimator.ofFloat(
              holder.pocket,
              View.TRANSLATION_X,
              View.TRANSLATION_Y,
              arc.getPath(translatedLeft, translatedTop, 0, 0));
      Animator pvhPocketScaleDown =
          ObjectAnimator.ofPropertyValuesHolder(
              holder.pocket,
              PropertyValuesHolder.ofFloat(View.SCALE_X, 1f),
              PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f));
      ObjectAnimator pocketFadeDown =
          ObjectAnimator.ofInt(holder.pocket, ViewUtils.IMAGE_ALPHA, 138);

      AnimatorSet down = new AnimatorSet();
      down.playTogether(titleMoveFadeIn, pocketMoveDown, pvhPocketScaleDown, pocketFadeDown);
      down.setDuration(300);
      down.setInterpolator(
          AnimationUtils.loadInterpolator(
              holder.itemView.getContext(), android.R.interpolator.fast_out_slow_in));
      down.setStartDelay(500);

      // play it
      AnimatorSet upDown = new AnimatorSet();
      upDown.playSequentially(up, down);

      // clean up
      upDown.addListener(
          new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animation) {
              dispatchAnimationStarted(holder);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
              ((ViewGroup) holder.pocket.getParent().getParent()).setClipChildren(true);
              holder.itemView.setHasTransientState(false);
              dispatchAnimationFinished(holder);
            }
          });
      upDown.start();
    }
    return super.animateChange(oldHolder, newHolder, preInfo, postInfo);
  }
Ejemplo n.º 10
0
 @Override
 public void setStartDelay(long startDelay) {
   mAnimatorSet.setStartDelay(startDelay);
 }
Ejemplo n.º 11
0
  private void setIsDay(final boolean isDay, boolean smoothTransition) {
    ObjectAnimator sunAnim =
        ObjectAnimator.ofInt(this, "sunOffset", sunOffset, isDay ? 0 : mViewHeight);
    sunAnim.setInterpolator(new AnticipateOvershootInterpolator());
    sunAnim.setDuration(smoothTransition ? ImageWithAlphaAndSize.ANIM_DURATION : 0);
    sunAnim.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {
            if (isDay) {
              mImageSun.setAlpha(ImageWithAlphaAndSize.OPAQUE);
            }
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            if (!isDay) {
              mImageSun.setAlpha(ImageWithAlphaAndSize.INVISIBLE);
            }
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });

    AnimatorSet dayAnims = new AnimatorSet();
    dayAnims.playTogether(
        // Day values
        mImageSkyDay.fadeTransition(isDay, smoothTransition),
        mImageMountainsDay.fadeTransition(isDay, smoothTransition),
        mPaintMountainsDay.fadeTransition(isDay, smoothTransition));

    ObjectAnimator moonAnim =
        ObjectAnimator.ofInt(this, "moonOffset", moonOffset, isDay ? -mViewHeight : 0);
    moonAnim.setInterpolator(new AnticipateOvershootInterpolator());
    moonAnim.setDuration(smoothTransition ? ImageWithAlphaAndSize.ANIM_DURATION : 0);
    moonAnim.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {
            if (!isDay) {
              mImageMoon.setAlpha(ImageWithAlphaAndSize.OPAQUE);
            }
          }

          @Override
          public void onAnimationEnd(Animator animation) {
            if (isDay) {
              mImageMoon.setAlpha(ImageWithAlphaAndSize.INVISIBLE);
            }
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });

    AnimatorSet nightAnims = new AnimatorSet();
    nightAnims.playTogether(
        // Night values
        mImageSkyNight.fadeTransition(!isDay, !isDay && smoothTransition),
        mImageMountainsNight.fadeTransition(!isDay, !isDay && smoothTransition),
        mPaintMountainsNight.fadeTransition(!isDay, !isDay && smoothTransition));
    // When going to the day, delay night animation till after day time has kicked in
    if (isDay) {
      nightAnims.setStartDelay(ImageWithAlphaAndSize.ANIM_DURATION);
    }

    mFinalAnimations = nightAnims;

    sunAnim.start();
    dayAnims.start();
    moonAnim.start();
    nightAnims.start();
  }