Search in sources :

Example 21 with ObjectAnimator

use of android.animation.ObjectAnimator in project UltimateAndroid by cymcsg.

the class MenuCircleShowingAnimation method setOpenAnimation.

/**
     * Set open animation for single button
     *
     * @param promotedAction
     * @param position
     * @return objectAnimator
     */
private ObjectAnimator setOpenAnimation(ImageButton promotedAction, int position) {
    ObjectAnimator objectAnimator;
    if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        objectAnimator = ObjectAnimator.ofFloat(promotedAction, View.TRANSLATION_Y, 0f, -px * (promotedActions.size() - position));
        objectAnimator.setRepeatCount(0);
        objectAnimator.setDuration(ANIMATION_TIME * (promotedActions.size() - position));
    } else {
        objectAnimator = ObjectAnimator.ofFloat(promotedAction, View.TRANSLATION_X, 0f, -px * (promotedActions.size() - position));
        objectAnimator.setRepeatCount(0);
        objectAnimator.setDuration(ANIMATION_TIME * (promotedActions.size() - position));
    }
    return objectAnimator;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator)

Example 22 with ObjectAnimator

use of android.animation.ObjectAnimator in project UltimateAndroid by cymcsg.

the class MenuCircleShowingAnimation method setCloseAnimation.

/**
     * Set close animation for single button
     *
     * @param promotedAction
     * @param position
     * @return objectAnimator
     */
private ObjectAnimator setCloseAnimation(ImageButton promotedAction, int position) {
    ObjectAnimator objectAnimator;
    if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        objectAnimator = ObjectAnimator.ofFloat(promotedAction, View.TRANSLATION_Y, -px * (promotedActions.size() - position), 0f);
        objectAnimator.setRepeatCount(0);
        objectAnimator.setDuration(ANIMATION_TIME * (promotedActions.size() - position));
    } else {
        objectAnimator = ObjectAnimator.ofFloat(promotedAction, View.TRANSLATION_X, -px * (promotedActions.size() - position), 0f);
        objectAnimator.setRepeatCount(0);
        objectAnimator.setDuration(ANIMATION_TIME * (promotedActions.size() - position));
    }
    return objectAnimator;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator)

Example 23 with ObjectAnimator

use of android.animation.ObjectAnimator in project UltimateAndroid by cymcsg.

the class Ripple method enter.

/**
     * Starts the enter animation.
     */
public void enter() {
    cancel();
    final int radiusDuration = (int) (1000 * Math.sqrt(mOuterRadius / WAVE_TOUCH_DOWN_ACCELERATION * mDensity) + 0.5);
    final ObjectAnimator radius = ObjectAnimator.ofFloat(this, "radiusGravity", 1);
    radius.setAutoCancel(true);
    radius.setDuration(radiusDuration);
    radius.setInterpolator(LINEAR_INTERPOLATOR);
    radius.setStartDelay(RIPPLE_ENTER_DELAY);
    final ObjectAnimator cX = ObjectAnimator.ofFloat(this, "xGravity", 1);
    cX.setAutoCancel(true);
    cX.setDuration(radiusDuration);
    cX.setInterpolator(LINEAR_INTERPOLATOR);
    cX.setStartDelay(RIPPLE_ENTER_DELAY);
    final ObjectAnimator cY = ObjectAnimator.ofFloat(this, "yGravity", 1);
    cY.setAutoCancel(true);
    cY.setDuration(radiusDuration);
    cY.setInterpolator(LINEAR_INTERPOLATOR);
    cY.setStartDelay(RIPPLE_ENTER_DELAY);
    mAnimRadius = radius;
    mAnimX = cX;
    mAnimY = cY;
    // Enter animations always run on the UI thread, since it's unlikely
    // that anything interesting is happening until the user lifts their
    // finger.
    radius.start();
    cX.start();
    cY.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Paint(android.graphics.Paint)

Example 24 with ObjectAnimator

use of android.animation.ObjectAnimator in project UltimateAndroid by cymcsg.

the class RippleBackground method exitSoftware.

private void exitSoftware(int opacityDuration, int inflectionDuration, int inflectionOpacity) {
    final ObjectAnimator outerOpacityAnim;
    if (inflectionDuration > 0) {
        // Outer opacity continues to increase for a bit.
        outerOpacityAnim = ObjectAnimator.ofFloat(this, "outerOpacity", inflectionOpacity / 255.0f);
        outerOpacityAnim.setAutoCancel(true);
        outerOpacityAnim.setDuration(inflectionDuration);
        outerOpacityAnim.setInterpolator(LINEAR_INTERPOLATOR);
        // Chain the outer opacity exit animation.
        final int outerDuration = opacityDuration - inflectionDuration;
        if (outerDuration > 0) {
            outerOpacityAnim.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    final ObjectAnimator outerFadeOutAnim = ObjectAnimator.ofFloat(RippleBackground.this, "outerOpacity", 0);
                    outerFadeOutAnim.setAutoCancel(true);
                    outerFadeOutAnim.setDuration(outerDuration);
                    outerFadeOutAnim.setInterpolator(LINEAR_INTERPOLATOR);
                    outerFadeOutAnim.addListener(mAnimationListener);
                    mAnimOuterOpacity = outerFadeOutAnim;
                    outerFadeOutAnim.start();
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                    animation.removeListener(this);
                }
            });
        } else {
            outerOpacityAnim.addListener(mAnimationListener);
        }
    } else {
        outerOpacityAnim = ObjectAnimator.ofFloat(this, "outerOpacity", 0);
        outerOpacityAnim.setAutoCancel(true);
        outerOpacityAnim.setDuration(opacityDuration);
        outerOpacityAnim.addListener(mAnimationListener);
    }
    mAnimOuterOpacity = outerOpacityAnim;
    outerOpacityAnim.start();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Paint(android.graphics.Paint)

Example 25 with ObjectAnimator

use of android.animation.ObjectAnimator in project UltimateAndroid by cymcsg.

the class DynamicGridModification method animateBounds.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void animateBounds(final View mobileView) {
    TypeEvaluator<Rect> sBoundEvaluator = new TypeEvaluator<Rect>() {

        public Rect evaluate(float fraction, Rect startValue, Rect endValue) {
            return new Rect(interpolate(startValue.left, endValue.left, fraction), interpolate(startValue.top, endValue.top, fraction), interpolate(startValue.right, endValue.right, fraction), interpolate(startValue.bottom, endValue.bottom, fraction));
        }

        public int interpolate(int start, int end, float fraction) {
            return (int) (start + fraction * (end - start));
        }
    };
    ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", sBoundEvaluator, mHoverCellCurrentBounds);
    hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            invalidate();
        }
    });
    hoverViewAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationStart(Animator animation) {
            mHoverAnimation = true;
            updateEnableState();
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mHoverAnimation = false;
            updateEnableState();
            reset(mobileView);
        }
    });
    hoverViewAnimator.start();
}
Also used : Rect(android.graphics.Rect) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) TypeEvaluator(android.animation.TypeEvaluator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator) TargetApi(android.annotation.TargetApi)

Aggregations

ObjectAnimator (android.animation.ObjectAnimator)767 Animator (android.animation.Animator)304 AnimatorSet (android.animation.AnimatorSet)209 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)202 PropertyValuesHolder (android.animation.PropertyValuesHolder)125 ValueAnimator (android.animation.ValueAnimator)111 View (android.view.View)99 Paint (android.graphics.Paint)68 TextView (android.widget.TextView)47 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)46 ViewGroup (android.view.ViewGroup)45 LinearInterpolator (android.view.animation.LinearInterpolator)36 Rect (android.graphics.Rect)34 ImageView (android.widget.ImageView)31 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)30 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)28 OvershootInterpolator (android.view.animation.OvershootInterpolator)27 ArrayList (java.util.ArrayList)21 Interpolator (android.view.animation.Interpolator)20 TargetApi (android.annotation.TargetApi)19