android.animation.AnimatorSet#playSequentially ( )源码实例Demo

下面列出了android.animation.AnimatorSet#playSequentially ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FreeFlow   文件: DefaultLayoutAnimator.java
/**
 * 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;
}
 
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();
}
 
源代码3 项目: ArcLayout   文件: DemoLikeTumblrActivity.java
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();
}
 
源代码4 项目: CoolAndroidAnim   文件: ThirdPellet.java
@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();
            }
        }
    });
}
 
源代码5 项目: UltimateAndroid   文件: DefaultLayoutAnimator.java
/**
 *
 */
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;
}
 
源代码6 项目: delion   文件: InfoBarContainerLayout.java
@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;
}
 
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();
}
 
源代码8 项目: TutosAndroidFrance   文件: MainActivity.java
@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();
}
 
源代码9 项目: TikTok   文件: AnimatorUtils.java
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();
}
 
源代码10 项目: PeriscopeLayout   文件: PeriscopeLayout.java
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;
}
 
源代码11 项目: AndroidChromium   文件: InfoBarContainerLayout.java
@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;
}
 
源代码12 项目: QuranAndroid   文件: QuranPageReadActivity.java
/**
 * 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();
}
 
源代码13 项目: 365browser   文件: BottomSheet.java
/**
 * 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;
}
 
源代码14 项目: WaveHeartRate   文件: WaveView.java
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();
    }
}
 
源代码15 项目: delion   文件: InfoBarContainerLayout.java
@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;
}
 
源代码16 项目: ArcLayout   文件: DemoLikeTumblrActivity.java
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();

}
 
源代码17 项目: Qiitanium   文件: OverlayTopMenuView.java
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();

  }
 
/**
 * @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);
}
 
源代码19 项目: LaunchEnr   文件: PopupContainerWithArrow.java
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()));
}
 
源代码20 项目: UltimateAndroid   文件: DefaultLayoutAnimator.java
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;
    }