Java Code Examples for com.nineoldandroids.animation.AnimatorSet#setStartDelay()

The following examples show how to use com.nineoldandroids.animation.AnimatorSet#setStartDelay() . 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: AnimationAdapter.java    From HPlayer with Apache License 2.0 6 votes vote down vote up
private void animateView(final ViewGroup parent, final View view) {
    if (mAnimationStartMillis == -1) {
        mAnimationStartMillis = System.currentTimeMillis();
    }

    ViewHelper.setAlpha(view, 0);

    Animator[] childAnimators;
    if (mDecoratedBaseAdapter instanceof AnimationAdapter) {
        childAnimators = ((AnimationAdapter) mDecoratedBaseAdapter).getAnimators(parent, view);
    } else {
        childAnimators = new Animator[0];
    }
    Animator[] animators = getAnimators(parent, view);
    Animator alphaAnimator = ObjectAnimator.ofFloat(view, ALPHA, 0, 1);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(concatAnimators(childAnimators, animators, alphaAnimator));
    set.setStartDelay(calculateAnimationDelay());
    set.setDuration(getAnimationDurationMillis());
    set.start();

    mAnimators.put(view.hashCode(), set);
}
 
Example 2
Source File: MenuItemTransitionBuilder.java    From android-transition with Apache License 2.0 6 votes vote down vote up
@Override
public void setupAnimation(@NonNull MenuItem mMenuItem, @NonNull TransitionControllerManager manager,
                           @IntRange(from = 0) int itemIndex, @IntRange(from = 0) int menuCount) {
    if(mDelayed!=null) {
        final int size = mDelayed.size();
        for (int i = 0; i < size; i++) {
            mDelayed.get(i).evaluate(manager.getTarget(), this);
        }
    }

    ObjectAnimator anim = new ObjectAnimator();
    anim.setValues(getValuesHolders());
    AnimatorSet set = new AnimatorSet();
    set.play(anim);
    set.setStartDelay((long) (itemIndex * mCascade * SCALE_FACTOR));
    set.setDuration((long) (SCALE_FACTOR - itemIndex * mCascade * SCALE_FACTOR));
    manager.addAnimatorSetAsTransition(set).setRange(mStart, mEnd);
}
 
Example 3
Source File: AnimationAdapter.java    From ALLGO with Apache License 2.0 6 votes vote down vote up
private void animateView(int position, ViewGroup parent, View view) {
	if (mAnimationStartMillis == -1) {
		mAnimationStartMillis = System.currentTimeMillis();
	}

	ViewHelper.setAlpha(view, 0);

	Animator[] childAnimators;
	if (mDecoratedBaseAdapter instanceof AnimationAdapter) {
		childAnimators = ((AnimationAdapter) mDecoratedBaseAdapter).getAnimators(parent, view);
	} else {
		childAnimators = new Animator[0];
	}
	Animator[] animators = getAnimators(parent, view);
	Animator alphaAnimator = ObjectAnimator.ofFloat(view, "alpha", 0, 1);

	AnimatorSet set = new AnimatorSet();
	set.playTogether(concatAnimators(childAnimators, animators, alphaAnimator));
	set.setStartDelay(calculateAnimationDelay());
	set.setDuration(getAnimationDurationMillis());
	set.start();

	mAnimators.put(view.hashCode(), set);
}
 
Example 4
Source File: AnimationAdapter.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private void animateView(final ViewGroup parent, final View view) {
    if (mAnimationStartMillis == -1) {
        mAnimationStartMillis = System.currentTimeMillis();
    }

    ViewHelper.setAlpha(view, 0);

    Animator[] childAnimators;
    if (mDecoratedBaseAdapter instanceof AnimationAdapter) {
        childAnimators = ((AnimationAdapter) mDecoratedBaseAdapter).getAnimators(parent, view);
    } else {
        childAnimators = new Animator[0];
    }
    Animator[] animators = getAnimators(parent, view);
    Animator alphaAnimator = ObjectAnimator.ofFloat(view, ALPHA, 0, 1);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(concatAnimators(childAnimators, animators, alphaAnimator));
    set.setStartDelay(calculateAnimationDelay());
    set.setDuration(getAnimationDurationMillis());
    set.start();

    mAnimators.put(view.hashCode(), set);
}
 
Example 5
Source File: SwitchAnimationUtil.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
private void runRotateAnimation(View view, long delay) {
	view.setAlpha(0);
	AnimatorSet set = new AnimatorSet();
	ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view,
			"rotation", 0f, 360f);
	ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(view, "scaleX",
			0f, 1f);
	ObjectAnimator objectAnimator3 = ObjectAnimator.ofFloat(view, "scaleY",
			0f, 1f);
	ObjectAnimator objectAnimator4 = ObjectAnimator.ofFloat(view, "alpha",
			0f, 1f);

	objectAnimator2.setInterpolator(new AccelerateInterpolator(1.0f));
	objectAnimator3.setInterpolator(new AccelerateInterpolator(1.0f));

	set.setDuration(mDuration);
	set.playTogether(objectAnimator, objectAnimator2, objectAnimator3,
			objectAnimator4);
	set.setStartDelay(delay);
	set.start();
}
 
Example 6
Source File: AnimationAdapter.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
private void animateView(final ViewGroup parent, final View view) {
    if (mAnimationStartMillis == -1) {
        mAnimationStartMillis = System.currentTimeMillis();
    }

    ViewHelper.setAlpha(view, 0);

    Animator[] childAnimators;
    if (mDecoratedBaseAdapter instanceof AnimationAdapter) {
        childAnimators = ((AnimationAdapter) mDecoratedBaseAdapter).getAnimators(parent, view);
    } else {
        childAnimators = new Animator[0];
    }
    Animator[] animators = getAnimators(parent, view);
    Animator alphaAnimator = ObjectAnimator.ofFloat(view, ALPHA, 0, 1);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(concatAnimators(childAnimators, animators, alphaAnimator));
    set.setStartDelay(calculateAnimationDelay());
    set.setDuration(getAnimationDurationMillis());
    set.start();

    mAnimators.put(view.hashCode(), set);
}
 
Example 7
Source File: ViewAnimator.java    From ListViewAnimations with Apache License 2.0 6 votes vote down vote up
/**
 * Animates given View.
 *
 * @param view the View that should be animated.
 */
private void animateView(final int position, @NonNull final View view, @NonNull final Animator[] animators) {
    if (mAnimationStartMillis == -1) {
        mAnimationStartMillis = SystemClock.uptimeMillis();
    }

    ViewHelper.setAlpha(view, 0);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(animators);
    set.setStartDelay(calculateAnimationDelay(position));
    set.setDuration(mAnimationDurationMillis);
    set.start();

    mAnimators.put(view.hashCode(), set);
}
 
Example 8
Source File: ResideMenu.java    From Libraries-for-Android-Developers with MIT License 6 votes vote down vote up
/**
 *
 * @param menuItem
 * @param menu_index the position of the menu;
 * @return
 */
private void showMenuItem(ResideMenuItem menuItem,int menu_index){

    layout_menu.addView(menuItem);
    ViewHelper.setAlpha(menuItem, 0);
    AnimatorSet scaleUp = new AnimatorSet();
    scaleUp.playTogether(
            ObjectAnimator.ofFloat(menuItem, "translationX", -100.f, 0.0f),
            ObjectAnimator.ofFloat(menuItem, "alpha", 0.0f, 1.0f)
    );

    scaleUp.setInterpolator(AnimationUtils.loadInterpolator(activity,
            android.R.anim.anticipate_overshoot_interpolator));
    // with animation;
    scaleUp.setStartDelay(50 * menu_index);
    scaleUp.setDuration(400).start();
}
 
Example 9
Source File: MenuRVAdapter.java    From AndroidSweetSheet with Apache License 2.0 5 votes vote down vote up
private void animation(MenuVH menuVH) {

        ViewHelper.setAlpha(menuVH.itemView, 0);

        ViewHelper.setTranslationY(menuVH.itemView, 300);
        ObjectAnimator translationY = ObjectAnimator.ofFloat(menuVH.itemView, "translationY", 500, 0);
        translationY.setDuration(300);
        translationY.setInterpolator(new OvershootInterpolator(1.6f));
        ObjectAnimator alphaIn = ObjectAnimator.ofFloat(menuVH.itemView, "alpha", 0, 1);
        alphaIn.setDuration(100);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(translationY, alphaIn);
        animatorSet.setStartDelay(30 * menuVH.getAdapterPosition());
        animatorSet.start();
    }
 
Example 10
Source File: MenuRVAdapter.java    From MousePaint with MIT License 5 votes vote down vote up
private void animation(MenuVH menuVH) {

        ViewHelper.setAlpha(menuVH.itemView, 0);

        ViewHelper.setTranslationY(menuVH.itemView, 300);
        ObjectAnimator translationY = ObjectAnimator.ofFloat(menuVH.itemView, "translationY", 500, 0);
        translationY.setDuration(300);
        translationY.setInterpolator(new OvershootInterpolator(1.6f));
        ObjectAnimator alphaIn = ObjectAnimator.ofFloat(menuVH.itemView, "alpha", 0, 1);
        alphaIn.setDuration(100);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(translationY, alphaIn);
        animatorSet.setStartDelay(30 * menuVH.getAdapterPosition());
        animatorSet.start();
    }
 
Example 11
Source File: SwitchAnimationUtil.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void runHorizonLeftAnimation(View view, long delay) {
	view.setAlpha(0);
	ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view,
			"translationX", -ViewUtils.getScreenWidth(), 0);
	objectAnimator.setInterpolator(new LinearInterpolator());
	ObjectAnimator objectAnimatorAlpha = ObjectAnimator.ofFloat(view,
			"alpha", 0f, 1f);
	AnimatorSet set = new AnimatorSet();
	set.setDuration(mDuration);
	set.setStartDelay(delay);
	set.playTogether(objectAnimator, objectAnimatorAlpha);
	set.start();
}
 
Example 12
Source File: SwitchAnimationUtil.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void runHorizonRightAnimation(View view, long delay) {
	view.setAlpha(0);
	ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view,
			"translationX", ViewUtils.getScreenWidth(), 0);
	objectAnimator.setInterpolator(new LinearInterpolator());
	ObjectAnimator objectAnimatorAlpha = ObjectAnimator.ofFloat(view,
			"alpha", 0f, 1f);
	AnimatorSet set = new AnimatorSet();
	set.setStartDelay(delay);
	set.setDuration(mDuration);
	set.playTogether(objectAnimator, objectAnimatorAlpha);
	set.start();
}
 
Example 13
Source File: SwitchAnimationUtil.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void runScaleAnimation(View view, long delay) {
	view.setAlpha(0);
	AnimatorSet set = new AnimatorSet();

	ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(view, "scaleX",
			0f, 1f);
	ObjectAnimator objectAnimator3 = ObjectAnimator.ofFloat(view, "scaleY",
			0f, 1f);
	ObjectAnimator objectAnimator4 = ObjectAnimator.ofFloat(view, "alpha",
			0f, 1f);
	set.setDuration(mDuration);
	set.playTogether(objectAnimator2, objectAnimator3, objectAnimator4);
	set.setStartDelay(delay);
	set.start();
}
 
Example 14
Source File: SwitchAnimationUtil.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void runFlipVertialAnimation(View view, long delay) {
	view.setAlpha(0);
	AnimatorSet set = new AnimatorSet();
	ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(view,
			"rotationX", -180f, 0f);
	ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(view, "alpha",
			0f, 1f);
	set.setDuration(mDuration);
	set.playTogether(objectAnimator1, objectAnimator2);
	set.setStartDelay(delay);
	set.start();
}
 
Example 15
Source File: SwitchAnimationUtil.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void runFlipHorizonAnimation(View view, long delay) {
	view.setAlpha(0);
	AnimatorSet set = new AnimatorSet();
	ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(view,
			"rotationY", -180f, 0f);
	ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(view, "alpha",
			0f, 1f);
	set.setDuration(mDuration);
	set.playTogether(objectAnimator1, objectAnimator2);
	set.setStartDelay(delay);
	set.start();
}