Search in sources :

Example 16 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project Context-Menu.Android by Yalantis.

the class MenuAdapter method buildChosenAnimation.

/**
     * Builds and runs chosen item and menu closing animation
     */
private void buildChosenAnimation(int childIndex) {
    List<Animator> fadeOutTextTopAnimatorList = new ArrayList<>();
    List<Animator> closeToBottomImageAnimatorList = new ArrayList<>();
    for (int i = 0; i < childIndex; i++) {
        View view = mMenuWrapper.getChildAt(i);
        resetVerticalAnimation(view, true);
        closeToBottomImageAnimatorList.add(AnimatorUtils.rotationCloseVertical(view));
        fadeOutTextTopAnimatorList.add(AnimatorUtils.fadeOutSet(mTextWrapper.getChildAt(i), mContext.getResources().getDimension(R.dimen.text_right_translation)));
    }
    AnimatorSet closeToBottom = new AnimatorSet();
    closeToBottom.playSequentially(closeToBottomImageAnimatorList);
    AnimatorSet fadeOutTop = new AnimatorSet();
    fadeOutTop.playSequentially(fadeOutTextTopAnimatorList);
    List<Animator> fadeOutTextBottomAnimatorList = new ArrayList<>();
    List<Animator> closeToTopAnimatorObjects = new ArrayList<>();
    for (int i = getItemCount() - 1; i > childIndex; i--) {
        View view = mMenuWrapper.getChildAt(i);
        resetVerticalAnimation(view, false);
        closeToTopAnimatorObjects.add(AnimatorUtils.rotationCloseVertical(view));
        fadeOutTextBottomAnimatorList.add(AnimatorUtils.fadeOutSet(mTextWrapper.getChildAt(i), mContext.getResources().getDimension(R.dimen.text_right_translation)));
    }
    AnimatorSet closeToTop = new AnimatorSet();
    closeToTop.playSequentially(closeToTopAnimatorObjects);
    AnimatorSet fadeOutBottom = new AnimatorSet();
    fadeOutBottom.playSequentially(fadeOutTextBottomAnimatorList);
    resetSideAnimation(mMenuWrapper.getChildAt(childIndex));
    ObjectAnimator closeToRight = AnimatorUtils.rotationCloseToRight(mMenuWrapper.getChildAt(childIndex));
    closeToRight.addListener(mChosenItemFinishAnimatorListener);
    AnimatorSet fadeOutChosenText = AnimatorUtils.fadeOutSet(mTextWrapper.getChildAt(childIndex), mContext.getResources().getDimension(R.dimen.text_right_translation));
    AnimatorSet imageFullAnimatorSet = new AnimatorSet();
    imageFullAnimatorSet.play(closeToBottom).with(closeToTop);
    AnimatorSet textFullAnimatorSet = new AnimatorSet();
    textFullAnimatorSet.play(fadeOutTop).with(fadeOutBottom);
    if (closeToBottomImageAnimatorList.size() >= closeToTopAnimatorObjects.size()) {
        imageFullAnimatorSet.play(closeToBottom).before(closeToRight);
        textFullAnimatorSet.play(fadeOutTop).before(fadeOutChosenText);
    } else {
        imageFullAnimatorSet.play(closeToTop).before(closeToRight);
        textFullAnimatorSet.play(fadeOutBottom).before(fadeOutChosenText);
    }
    AnimatorSet fullAnimatorSet = new AnimatorSet();
    fullAnimatorSet.playTogether(imageFullAnimatorSet, textFullAnimatorSet);
    fullAnimatorSet.setDuration(mAnimationDurationMilis);
    fullAnimatorSet.setInterpolator(new HesitateInterpolator());
    fullAnimatorSet.start();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) ArrayList(java.util.ArrayList) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) View(android.view.View)

Example 17 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project Carbon by ZieIony.

the class RippleForeground method createSoftwareEnter.

@Override
protected Animator createSoftwareEnter(boolean fast) {
    // Bounded ripples don't have enter animations.
    if (mIsBounded) {
        return null;
    }
    final int duration = (int) (1000 * Math.sqrt(mTargetRadius / WAVE_TOUCH_DOWN_ACCELERATION * mDensity) + 0.5);
    final ObjectAnimator tweenRadius = ObjectAnimator.ofFloat(this, TWEEN_RADIUS, 1);
    AnimatorsCompat.setAutoCancel(tweenRadius);
    //  tweenRadius.setAutoCancel(true);
    tweenRadius.setDuration(duration);
    tweenRadius.setInterpolator(LINEAR_INTERPOLATOR);
    tweenRadius.setStartDelay(RIPPLE_ENTER_DELAY);
    final ObjectAnimator tweenOrigin = ObjectAnimator.ofFloat(this, TWEEN_ORIGIN, 1);
    AnimatorsCompat.setAutoCancel(tweenOrigin);
    // tweenOrigin.setAutoCancel(true);
    tweenOrigin.setDuration(duration);
    tweenOrigin.setInterpolator(LINEAR_INTERPOLATOR);
    tweenOrigin.setStartDelay(RIPPLE_ENTER_DELAY);
    final ObjectAnimator opacity = ObjectAnimator.ofFloat(this, OPACITY, 1);
    AnimatorsCompat.setAutoCancel(opacity);
    // opacity.setAutoCancel(true);
    opacity.setDuration(OPACITY_ENTER_DURATION_FAST);
    opacity.setInterpolator(LINEAR_INTERPOLATOR);
    final AnimatorSet set = new AnimatorSet();
    set.play(tweenOrigin).with(tweenRadius).with(opacity);
    return set;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) Paint(android.graphics.Paint)

Example 18 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project Carbon by ZieIony.

the class RippleBackground method createSoftwareEnter.

@Override
protected Animator createSoftwareEnter(boolean fast) {
    // Linear enter based on current opacity.
    final int maxDuration = fast ? OPACITY_ENTER_DURATION_FAST : OPACITY_ENTER_DURATION;
    final int duration = (int) ((1 - mOpacity) * maxDuration);
    final ObjectAnimator opacity = ObjectAnimator.ofFloat(this, OPACITY, 1);
    AnimatorsCompat.setAutoCancel(opacity);
    //opacity.setAutoCancel(true);
    opacity.setDuration(duration);
    opacity.setInterpolator(LINEAR_INTERPOLATOR);
    return opacity;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Paint(android.graphics.Paint)

Example 19 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project Carbon by ZieIony.

the class RippleBackground method createSoftwareExit.

@Override
protected Animator createSoftwareExit() {
    final AnimatorSet set = new AnimatorSet();
    // Linear exit after enter is completed.
    final ObjectAnimator exit = ObjectAnimator.ofFloat(this, RippleBackground.OPACITY, 0);
    exit.setInterpolator(LINEAR_INTERPOLATOR);
    exit.setDuration(OPACITY_EXIT_DURATION);
    AnimatorsCompat.setAutoCancel(exit);
    //exit.setAutoCancel(true);
    final AnimatorSet.Builder builder = set.play(exit);
    // Linear "fast" enter based on current opacity.
    final int fastEnterDuration = (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST);
    if (fastEnterDuration > 0) {
        final ObjectAnimator enter = ObjectAnimator.ofFloat(this, RippleBackground.OPACITY, 1);
        enter.setInterpolator(LINEAR_INTERPOLATOR);
        enter.setDuration(fastEnterDuration);
        AnimatorsCompat.setAutoCancel(enter);
        //enter.setAutoCancel(true);
        builder.after(enter);
    }
    return set;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) Paint(android.graphics.Paint)

Example 20 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project MaterialDesignLibrary by navasmdc.

the class ButtonFloat method show.

public void show() {
    ObjectAnimator animator = ObjectAnimator.ofFloat(ButtonFloat.this, "y", showPosition);
    animator.setInterpolator(new BounceInterpolator());
    animator.setDuration(1500);
    animator.start();
    isShow = true;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) BounceInterpolator(android.view.animation.BounceInterpolator)

Aggregations

ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)81 AnimatorSet (com.nineoldandroids.animation.AnimatorSet)27 Animator (com.nineoldandroids.animation.Animator)20 View (android.view.View)11 PropertyValuesHolder (com.nineoldandroids.animation.PropertyValuesHolder)10 Keyframe (com.nineoldandroids.animation.Keyframe)9 Paint (android.graphics.Paint)8 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 TextView (android.widget.TextView)5 AdapterView (android.widget.AdapterView)4 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)4 SuppressLint (android.annotation.SuppressLint)3 TargetApi (android.annotation.TargetApi)3 LinearInterpolator (android.view.animation.LinearInterpolator)3 OvershootInterpolator (android.view.animation.OvershootInterpolator)3 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)3 SupportAnimator (io.codetail.animation.SupportAnimator)3