Java Code Examples for android.animation.AnimatorSet#playSequentially()

The following examples show how to use android.animation.AnimatorSet#playSequentially() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CapturePhotoFragment.java    From MediaPickerInstagram with Apache License 2.0 6 votes vote down vote up
private void animateShutter() {
    mShutter.setVisibility(View.VISIBLE);
    mShutter.setAlpha(0.f);

    ObjectAnimator alphaInAnim = ObjectAnimator.ofFloat(mShutter, "alpha", 0f, 0.8f);
    alphaInAnim.setDuration(100);
    alphaInAnim.setStartDelay(100);
    alphaInAnim.setInterpolator(ACCELERATE_INTERPOLATOR);

    ObjectAnimator alphaOutAnim = ObjectAnimator.ofFloat(mShutter, "alpha", 0.8f, 0f);
    alphaOutAnim.setDuration(200);
    alphaOutAnim.setInterpolator(DECELERATE_INTERPOLATOR);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playSequentially(alphaInAnim, alphaOutAnim);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mShutter.setVisibility(View.GONE);
        }
    });
    animatorSet.start();
}
 
Example 2
Source File: DefaultLayoutAnimator.java    From FreeFlow with Apache License 2.0 6 votes vote down vote up
/**
 * The animation to run on the items being removed
 * 
 * @param removed
 *            An ArrayList of <code>FreeFlowItems</code> removed
 * @return The AnimatorSet of the removed objects
 */
protected AnimatorSet getItemsRemovedAnimation(List<FreeFlowItem> removed) {
	AnimatorSet disappearingSet = new AnimatorSet();
	ArrayList<Animator> fades = new ArrayList<Animator>();
	for (FreeFlowItem proxy : removed) {
		fades.add(ObjectAnimator.ofFloat(proxy.view, "alpha", 0));
	}
	disappearingSet.setDuration(oldCellsRemovalAnimationDuration);
	disappearingSet.setStartDelay(oldCellsRemovalAnimationStartDelay);

	if (animateIndividualCellsSequentially)
		disappearingSet.playSequentially(fades);
	else
		disappearingSet.playTogether(fades);

	return disappearingSet;
}
 
Example 3
Source File: ActionTeslaFragment.java    From rnd-android-wear-tesla with MIT License 6 votes vote down vote up
private void performActionAnimation(View view) {
    ValueAnimator startAnim = ValueAnimator.ofInt(mNormalImageSize, getSizeFromCoef(START_ANIMATION_OUT_SCALE_END));
    startAnim.addUpdateListener(new ScaleAnimateListener(view));
    startAnim.setDuration(START_ANIMATION_TIME);

    AnimatorSet middleAnim = new AnimatorSet();
    ValueAnimator middleOutScale = ValueAnimator.ofInt(getSizeFromCoef(MIDDLE_ANIMATION_OUT_SCALE_START), getSizeFromCoef(MIDDLE_ANIMATION_OUT_SCALE_END));
    middleOutScale.addUpdateListener(new ScaleAnimateListener(view));
    ValueAnimator middleInAlpha = ValueAnimator.ofFloat(MIDDLE_ANIMATION_IN_ALPHA_START, MIDDLE_ANIMATION_IN_ALPHA_END);
    middleInAlpha.addUpdateListener(new AlphaAnimateListener(view));
    middleAnim.playTogether(middleOutScale, middleInAlpha);
    middleAnim.setDuration(MIDDLE_ANIMATION_TIME);

    AnimatorSet endAnim = new AnimatorSet();
    ValueAnimator endInScale = ValueAnimator.ofInt(getSizeFromCoef(END_ANIMATION_IN_SCALE_START), getSizeFromCoef(END_ANIMATION_IN_SCALE_END));
    endInScale.addUpdateListener(new ScaleAnimateListener(view));
    ValueAnimator endInAlpha = ValueAnimator.ofFloat(END_ANIMATION_IN_ALPHA_START, END_ANIMATION_IN_ALPHA_END);
    endInAlpha.addUpdateListener(new AlphaAnimateListener(view));
    endAnim.playTogether(endInScale, endInAlpha);
    endAnim.setDuration(END_ANIMATION_TIME);

    AnimatorSet mainAnim = new AnimatorSet();
    mainAnim.playSequentially(startAnim, middleAnim, endAnim);
    mainAnim.setInterpolator(new LinearInterpolator());
    mainAnim.start();
}
 
Example 4
Source File: DemoLikeTumblrActivity.java    From ArcLayout with Apache License 2.0 6 votes vote down vote up
private void showMenu(int cx, int cy, float startRadius, float endRadius) {
  menuLayout.setVisibility(View.VISIBLE);

  List<Animator> animList = new ArrayList<>();

  Animator revealAnim = createCircularReveal(menuLayout, cx, cy, startRadius, endRadius);
  revealAnim.setInterpolator(new AccelerateDecelerateInterpolator());
  revealAnim.setDuration(200);

  animList.add(revealAnim);
  animList.add(createShowItemAnimator(centerItem));

  for (int i = 0, len = arcLayout.getChildCount(); i < len; i++) {
    animList.add(createShowItemAnimator(arcLayout.getChildAt(i)));
  }

  AnimatorSet animSet = new AnimatorSet();
  animSet.playSequentially(animList);
  animSet.start();
}
 
Example 5
Source File: DefaultLayoutAnimator.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
protected AnimatorSet getItemsAddedAnimation(List<FreeFlowItem> added) {
    AnimatorSet appearingSet = new AnimatorSet();
    ArrayList<Animator> fadeIns = new ArrayList<Animator>();
    for (FreeFlowItem proxy : added) {
        proxy.view.setAlpha(0);
        fadeIns.add(ObjectAnimator.ofFloat(proxy.view, "alpha", 1));
    }

    if (animateIndividualCellsSequentially)
        appearingSet.playSequentially(fadeIns);
    else
        appearingSet.playTogether(fadeIns);

    appearingSet.setStartDelay(newCellsAdditionAnimationStartDelay);
    appearingSet.setDuration(newCellsAdditionAnimationDurationPerCell);
    return appearingSet;
}
 
Example 6
Source File: InfoBarContainerLayout.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
Animator createAnimator() {
    int deltaHeight = mNewContents.getHeight() - mOldContents.getHeight();
    InfoBarContainerLayout.this.setTranslationY(Math.max(0, deltaHeight));
    mNewContents.setAlpha(0f);

    AnimatorSet animator = new AnimatorSet();
    animator.playSequentially(
            ObjectAnimator.ofFloat(mOldContents, View.ALPHA, 0f)
                    .setDuration(DURATION_FADE_OUT_MS),
            ObjectAnimator.ofFloat(InfoBarContainerLayout.this, View.TRANSLATION_Y,
                    Math.max(0, -deltaHeight)).setDuration(DURATION_SLIDE_UP_MS),
            ObjectAnimator.ofFloat(mNewContents, View.ALPHA, 1f)
                    .setDuration(DURATION_FADE_OUT_MS));
    return animator;
}
 
Example 7
Source File: ThirdPellet.java    From CoolAndroidAnim with Apache License 2.0 6 votes vote down vote up
@Override
protected void initAnim() {
    mAnimatorSet = new AnimatorSet();
    // 放大弹出射线

    // 绿色圆弧包围红色圆,内部先产生间隔,红色圆膨胀,然后绿色圆弧和红色圆膨胀效果
    ValueAnimator flattenAnim = createFlattenAnim();
    // 等待黄色圆传递
    ValueAnimator waitForAnim = ValueAnimator.ofFloat(0, 100);
    waitForAnim.setDuration(mDuration2);
    // 黄色圆缩小,绿色弧线出现,旋转从0->-120,从-120->-240,抛出黄色小球,绿色弧线逐渐变成球,
    // 红色弧线绕圈,逐渐合并为圆环,
    ValueAnimator smallerAndRotateAnim = createSmallerAndRotateAnim();
    // 红色弧线往内缩,绿色圆放大,回到膨胀效果
    ValueAnimator backAnim = createBackAnim();

    mAnimatorSet.playSequentially(flattenAnim, waitForAnim, smallerAndRotateAnim, backAnim);
    mAnimatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (mAnimatorStateListen != null) {
                mAnimatorStateListen.onAnimatorEnd();
            }
        }
    });
}
 
Example 8
Source File: InfoBarContainerLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
Animator createAnimator() {
    mFrontWrapper.setTranslationY(mFrontWrapper.getHeight());
    mFrontContents.setAlpha(0f);

    AnimatorSet animator = new AnimatorSet();
    animator.playSequentially(
            createTranslationYAnimator(mFrontWrapper, 0f)
                    .setDuration(DURATION_SLIDE_UP_MS),
            ObjectAnimator.ofFloat(mFrontContents, View.ALPHA, 1f)
                    .setDuration(DURATION_FADE_MS));
    return animator;
}
 
Example 9
Source File: WaveView.java    From WaveHeartRate with Apache License 2.0 5 votes vote down vote up
private void doAnimation(int value, long duration){
    if(value == 0){
        Animator animator = getLineAnimator(m_LineObjects, duration);
        animator.addListener(this);
        animator.start();
    }else{
        AnimatorSet set = new AnimatorSet();
        List<Animator> peakAnim = getPeakAnimator(duration);
        set.playSequentially(peakAnim);
        set.start();
    }
}
 
Example 10
Source File: BottomSheet.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a transition animation between two views. The old view is faded out completely
 * before the new view is faded in. There is an option to detach the old view or not.
 * @param newView The new view to transition to.
 * @param oldView The old view to transition from.
 * @param detachOldView Whether or not to detach the old view once faded out.
 * @return An animator that runs the specified animation.
 */
private Animator getViewTransitionAnimator(final View newView, final View oldView,
        final ViewGroup parent, final boolean detachOldView) {
    if (newView == oldView) return null;

    AnimatorSet animatorSet = new AnimatorSet();
    List<Animator> animators = new ArrayList<>();

    // Fade out the old view.
    if (oldView != null) {
        ValueAnimator fadeOutAnimator = ObjectAnimator.ofFloat(oldView, View.ALPHA, 0);
        fadeOutAnimator.setDuration(TRANSITION_DURATION_MS);
        fadeOutAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (detachOldView && oldView.getParent() != null) {
                    parent.removeView(oldView);
                }
            }
        });
        animators.add(fadeOutAnimator);
    }

    // Fade in the new view.
    if (parent != newView.getParent()) parent.addView(newView);
    newView.setAlpha(0);
    ValueAnimator fadeInAnimator = ObjectAnimator.ofFloat(newView, View.ALPHA, 1);
    fadeInAnimator.setDuration(TRANSITION_DURATION_MS);
    animators.add(fadeInAnimator);

    animatorSet.playSequentially(animators);

    return animatorSet;
}
 
Example 11
Source File: QuranPageReadActivity.java    From QuranAndroid with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Function to show footer
 */
public void showFooter() {
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    screenHeight = metrics.heightPixels;
    ObjectAnimator animY = ObjectAnimator.ofFloat(footerContainer, "y", screenHeight
            - footerContainer.getHeight());
    AnimatorSet animSetXY = new AnimatorSet();
    animSetXY.setInterpolator(new LinearInterpolator());
    animSetXY.playSequentially(animY);
    animSetXY.start();
}
 
Example 12
Source File: MainActivity.java    From TutosAndroidFrance with MIT License 5 votes vote down vote up
@OnClick(R.id.sequentially)
public void animateSequentially() {
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playSequentially(
            ObjectAnimator.ofFloat(image, "translationX", 0, 100, -100, 0),
            ObjectAnimator.ofFloat(image, "translationY", 0, 100, -100, 0),
            ObjectAnimator.ofFloat(image, "alpha", 1, 0.5f, 1)
    );
    animatorSet.setDuration(1000);
    animatorSet.setInterpolator(new AccelerateInterpolator());
    animatorSet.start();
}
 
Example 13
Source File: DemoLikeTumblrActivity.java    From ArcLayout with Apache License 2.0 5 votes vote down vote up
private void hideMenu(int cx, int cy, float startRadius, float endRadius) {
  List<Animator> animList = new ArrayList<>();

  for (int i = arcLayout.getChildCount() - 1; i >= 0; i--) {
    animList.add(createHideItemAnimator(arcLayout.getChildAt(i)));
  }

  animList.add(createHideItemAnimator(centerItem));

  Animator revealAnim = createCircularReveal(menuLayout, cx, cy, startRadius, endRadius);
  revealAnim.setInterpolator(new AccelerateDecelerateInterpolator());
  revealAnim.setDuration(200);
  revealAnim.addListener(new AnimatorListenerAdapter() {
    @Override
    public void onAnimationEnd(Animator animation) {
      super.onAnimationEnd(animation);
      menuLayout.setVisibility(View.INVISIBLE);
    }
  });

  animList.add(revealAnim);

  AnimatorSet animSet = new AnimatorSet();
  animSet.playSequentially(animList);
  animSet.start();

}
 
Example 14
Source File: InfoBarContainerLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
Animator createAnimator() {
    mFrontWrapper.setTranslationY(mFrontWrapper.getHeight());
    mFrontContents.setAlpha(0f);

    AnimatorSet animator = new AnimatorSet();
    animator.playSequentially(
            createTranslationYAnimator(mFrontWrapper, 0f)
                    .setDuration(DURATION_SLIDE_UP_MS),
            ObjectAnimator.ofFloat(mFrontContents, View.ALPHA, 1f)
                    .setDuration(DURATION_FADE_MS));
    return animator;
}
 
Example 15
Source File: PeriscopeLayout.java    From PeriscopeLayout with Apache License 2.0 5 votes vote down vote up
private Animator getAnimator(View target) {
    AnimatorSet set = getEnterAnimtor(target);

    ValueAnimator bezierValueAnimator = getBezierValueAnimator(target);

    AnimatorSet finalSet = new AnimatorSet();
    finalSet.playSequentially(set);
    finalSet.playSequentially(set, bezierValueAnimator);
    finalSet.setInterpolator(interpolators[random.nextInt(4)]);
    finalSet.setTarget(target);
    return finalSet;
}
 
Example 16
Source File: AnimatorUtils.java    From TikTok with Apache License 2.0 5 votes vote down vote up
public static void playAnimatorArray(ArrayList<Animator> animators, AnimatorPlayType playType){
    AnimatorSet set = new AnimatorSet();
    switch (playType){
        case Sequentially:
            set.playSequentially(animators);
            break;
        case Together:
            set.playTogether(animators);
            break;
    }
    set.start();
}
 
Example 17
Source File: DefaultLayoutAnimator.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
protected AnimatorSet getAnimationSequence() {

        if (disappearingSet == null && appearingSet == null && movingSet == null)
            return null;

        AnimatorSet allAnim = new AnimatorSet();

        ArrayList<Animator> all = new ArrayList<Animator>();

        if (disappearingSet != null)
            all.add(disappearingSet);

        if (appearingSet != null)
            all.add(appearingSet);

        if (movingSet != null)
            all.add(movingSet);

        if (animateAllSetsSequentially)
            allAnim.playSequentially(all);
        else
            allAnim.playTogether(all);

        return allAnim;
    }
 
Example 18
Source File: PopupContainerWithArrow.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
public void trimNotifications(Map<PackageUserKey, BadgeInfo> updatedBadges) {
    if (mNotificationItemView == null) {
        return;
    }
    ItemInfo originalInfo = (ItemInfo) mOriginalIcon.getTag();
    BadgeInfo badgeInfo = updatedBadges.get(PackageUserKey.fromItemInfo(originalInfo));
    if (badgeInfo == null || badgeInfo.getNotificationKeys().size() == 0) {
        AnimatorSet removeNotification = LauncherAnimUtils.createAnimatorSet();
        final int duration = getResources().getInteger(
                R.integer.config_removeNotificationViewDuration);
        final int spacing = getResources().getDimensionPixelSize(R.dimen.popup_items_spacing);
        removeNotification.play(reduceNotificationViewHeight(
                mNotificationItemView.getHeightMinusFooter() + spacing, duration));
        final View removeMarginView = mIsAboveIcon ? getItemViewAt(getItemCount() - 2)
                : mNotificationItemView;
        if (removeMarginView != null) {
            ValueAnimator removeMargin = ValueAnimator.ofFloat(1, 0).setDuration(duration);
            removeMargin.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    ((MarginLayoutParams) removeMarginView.getLayoutParams()).bottomMargin
                            = (int) (spacing * (float) valueAnimator.getAnimatedValue());
                }
            });
            removeNotification.play(removeMargin);
        }
        Animator fade = ObjectAnimator.ofFloat(mNotificationItemView, ALPHA, 0)
                .setDuration(duration);
        fade.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                removeView(mNotificationItemView);
                mNotificationItemView = null;
                if (getItemCount() == 0) {
                    close(false);
                    return;
                }
            }
        });
        removeNotification.play(fade);
        final long arrowScaleDuration = getResources().getInteger(
                R.integer.config_deepShortcutArrowOpenDuration);
        Animator hideArrow = createArrowScaleAnim(0).setDuration(arrowScaleDuration);
        hideArrow.setStartDelay(0);
        Animator showArrow = createArrowScaleAnim(1).setDuration(arrowScaleDuration);
        showArrow.setStartDelay((long) (duration - arrowScaleDuration * 1.5));
        removeNotification.playSequentially(hideArrow, showArrow);
        removeNotification.start();
        return;
    }
    mNotificationItemView.trimNotifications(NotificationKeyData.extractKeysOnly(
            badgeInfo.getNotificationKeys()));
}
 
Example 19
Source File: ToolbarProgressBarAnimatingView.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @param context The Context for this view.
 * @param height The LayoutParams for this view.
 */
public ToolbarProgressBarAnimatingView(Context context, LayoutParams layoutParams) {
    super(context);
    setLayoutParams(layoutParams);
    mIsRtl = LocalizationUtils.isLayoutRtl();
    mDpToPx = getResources().getDisplayMetrics().density;

    mAnimationDrawable = new ColorDrawable(Color.WHITE);

    setImageDrawable(mAnimationDrawable);

    mListener = new ProgressBarUpdateListener();
    mAnimatorSet = new AnimatorSet();

    mSlowAnimation = new ValueAnimator();
    mSlowAnimation.setFloatValues(0.0f, 1.0f);
    mSlowAnimation.addUpdateListener(mListener);

    mFastAnimation = new ValueAnimator();
    mFastAnimation.setFloatValues(0.0f, 1.0f);
    mFastAnimation.addUpdateListener(mListener);

    updateAnimationDuration();

    mAnimatorSet.playSequentially(mSlowAnimation, mFastAnimation);

    AnimatorListener listener = new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator a) {
            // Replay the animation if it has not been canceled.
            if (mIsCanceled) return;
            // Repeats of the animation should have a start delay.
            mAnimatorSet.setStartDelay(ANIMATION_DELAY_MS);
            updateAnimationDuration();
            // Only restart the animation if the last animation is ending.
            if (a == mFastAnimation) mAnimatorSet.start();
        }
    };

    mSlowAnimation.addListener(listener);
    mFastAnimation.addListener(listener);
}
 
Example 20
Source File: OverlayTopMenuView.java    From Qiitanium with MIT License 4 votes vote down vote up
public void turnOff() {

    final float homeX = ViewUtils.getCenterX(homeBtn);
    final float refreshX = ViewUtils.getCenterX(refreshBtn);
    final float settingX = ViewUtils.getCenterX(settingBtn);

    AnimatorSet animSet = new AnimatorSet();

    animSet.playSequentially(
        AnimatorUtils.together(
            new DecelerateInterpolator(),
            AnimatorUtils.fadeOut(homeLabel),
            AnimatorUtils.fadeOut(refreshLabel),
            AnimatorUtils.fadeOut(settingLabel)
        ).setDuration(50),
        AnimatorUtils.together(
            new AnticipateInterpolator(),
            AnimatorUtils.of(
                refreshBtn,
                AnimatorUtils.ofTranslationX(0f, homeX - refreshX),
                AnimatorUtils.ofAlpha(1f, 0f),
                AnimatorUtils.ofScaleX(1f, 0f),
                AnimatorUtils.ofScaleY(1f, 0f)
            ).setDuration(400),
            AnimatorUtils.of(
                homeBtn,
                AnimatorUtils.ofAlpha(1f, 0f),
                AnimatorUtils.ofScaleX(1f, 0f),
                AnimatorUtils.ofScaleY(1f, 0f)
            ).setDuration(300),
            AnimatorUtils.of(
                settingBtn,
                AnimatorUtils.ofTranslationX(0f, homeX - settingX),
                AnimatorUtils.ofAlpha(1f, 0f),
                AnimatorUtils.ofScaleX(1f, 0f),
                AnimatorUtils.ofScaleY(1f, 0f)
            ).setDuration(200)
        ),
        AnimatorUtils.fadeOut(layout).setDuration(50)
    );

    animSet.addListener(new AnimatorListenerAdapter() {
      @Override
      public void onAnimationEnd(Animator animation) {
        layoutToggle.setSelected(false);
        ViewUtils.setInvisible(layout);
        AnimatorUtils.reset(homeBtn);
        AnimatorUtils.reset(refreshBtn);
        AnimatorUtils.reset(settingBtn);
      }
    });

    animSet.start();

  }