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

The following examples show how to use com.nineoldandroids.animation.AnimatorSet#play() . 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: 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 2
Source File: MaterialCompoundButton.java    From MaterialRadioGroup with Apache License 2.0 5 votes vote down vote up
private void start() {
    if(canAnimate()){
        clearAnimation();
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(ObjectAnimator.ofFloat(this, "scaleX", 1.0f));
    animatorSet.play(ObjectAnimator.ofFloat(this, "scaleY", 1.0f));
    animatorSet.setInterpolator(new OvershootInterpolator());
    animatorSet.setDuration(getDuration());
    animatorSet.start();
}
 
Example 3
Source File: MaterialCompoundButton.java    From MaterialRadioGroup with Apache License 2.0 5 votes vote down vote up
private void end() {
    if(canAnimate()){
        clearAnimation();
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(ObjectAnimator.ofFloat(this, "scaleX", 0.85f));
    animatorSet.play(ObjectAnimator.ofFloat(this, "scaleY", 0.85f));
    animatorSet.setInterpolator(new OvershootInterpolator());
    animatorSet.setDuration(getDuration());
    animatorSet.start();
}
 
Example 4
Source File: ViewTransitionBuilder.java    From android-transition with Apache License 2.0 5 votes vote down vote up
@Override
public void setupAnimation(@NonNull TransitionControllerManager manager) {
    if (mView == null) {
        mView = manager.getTarget();
    }

    if (mDelayed != null) {
        for (int i = 0, size = mDelayed.size(); i < size; i++) {
            mDelayed.get(i).evaluate(manager.getTarget(), this);
        }
    }

    for (int i = 0, size = mSetupList.size(); i < size; i++) {
        mSetupList.get(i).setupAnimation(manager);
    }

    if (mCustomTransitionController != null) {
        mCustomTransitionController.setTarget(manager.getTarget());
        mCustomTransitionController.setRange(mStart, mEnd);
        manager.addTransitionController(mCustomTransitionController.clone());
    }

    ObjectAnimator anim = new ObjectAnimator();
    anim.setTarget(mView);
    anim.setValues(getValuesHolders());
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(anim);
    animatorSet.setDuration(SCALE_FACTOR);
    manager.addAnimatorSetAsTransition(mView, animatorSet).setRange(mStart, mEnd);
}
 
Example 5
Source File: MaterialRippleLayoutNineOld.java    From AdvancedMaterialDrawer with Apache License 2.0 5 votes vote down vote up
private void startRipple(final Runnable animationEndRunnable) {
    if (eventCancelled) return;

    float endRadius = getEndRadius();

    cancelAnimations();

    rippleAnimator = new AnimatorSet();
    rippleAnimator.addListener(new AnimatorListenerAdapter() {
        @Override public void onAnimationEnd(Animator animation) {
            if (!ripplePersistent) {
                setRadius(0);
                setRippleAlpha(rippleAlpha);
            }
            if (animationEndRunnable != null && rippleDelayClick) {
                animationEndRunnable.run();
            }
            childView.setPressed(false);
        }
    });

    ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius);
    ripple.setDuration(rippleDuration);
    ripple.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0);
    fade.setDuration(rippleFadeDuration);
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY);

    if (ripplePersistent) {
        rippleAnimator.play(ripple);
    } else if (getRadius() > endRadius) {
        fade.setStartDelay(0);
        rippleAnimator.play(fade);
    } else {
        rippleAnimator.playTogether(ripple, fade);
    }
    rippleAnimator.start();
}
 
Example 6
Source File: TransitionControllerManager.java    From android-transition with Apache License 2.0 2 votes vote down vote up
/**
 * Adds an Animator as {@link TransitionController}
 *
 * @param mAnim
 * @return
 */
public TransitionController addAnimatorAsTransition(@NonNull Animator mAnim) {
    AnimatorSet as = new AnimatorSet();
    as.play(mAnim);
    return addAnimatorSetAsTransition(null, as);
}
 
Example 7
Source File: TransitionControllerManager.java    From android-transition with Apache License 2.0 2 votes vote down vote up
/**
 * Adds an Animator as {@link TransitionController}
 *
 * @param target
 * @param animator
 * @return
 */
public TransitionController addAnimatorAsTransition(@Nullable View target, @NonNull Animator animator) {
    AnimatorSet as = new AnimatorSet();
    as.play(animator);
    return addAnimatorSetAsTransition(target, as);
}
 
Example 8
Source File: DefaultTransitionController.java    From android-transition with Apache License 2.0 2 votes vote down vote up
/**
 * Wraps an Animator as a DefaultTransitionController
 *
 * @param anim
 * @return
 */
public static DefaultTransitionController wrapAnimator(@NonNull Animator anim) {
    AnimatorSet set = new AnimatorSet();
    set.play(anim);
    return new DefaultTransitionController(set);
}