Search in sources :

Example 31 with ObjectAnimator

use of android.animation.ObjectAnimator in project weiciyuan by qii.

the class AnimationUtils method createMovementAnimation.

public static AnimatorSet createMovementAnimation(View view, float x, float y) {
    ObjectAnimator alphaIn = ObjectAnimator.ofFloat(view, ALPHA, INVISIBLE, VISIBLE).setDuration(500);
    ObjectAnimator setUpX = ObjectAnimator.ofFloat(view, COORD_X, x).setDuration(INSTANT);
    ObjectAnimator setUpY = ObjectAnimator.ofFloat(view, COORD_Y, y).setDuration(INSTANT);
    AnimatorSet as = new AnimatorSet();
    as.play(setUpX).with(setUpY).before(alphaIn);
    return as;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet)

Example 32 with ObjectAnimator

use of android.animation.ObjectAnimator in project weiciyuan by qii.

the class AnimationUtils method createMovementAnimation.

public static AnimatorSet createMovementAnimation(View view, float canvasX, float canvasY, float offsetStartX, float offsetStartY, float offsetEndX, float offsetEndY, final AnimationEndListener listener) {
    view.setAlpha(INVISIBLE);
    ObjectAnimator alphaIn = ObjectAnimator.ofFloat(view, ALPHA, INVISIBLE, VISIBLE).setDuration(500);
    ObjectAnimator setUpX = ObjectAnimator.ofFloat(view, COORD_X, canvasX + offsetStartX).setDuration(INSTANT);
    ObjectAnimator setUpY = ObjectAnimator.ofFloat(view, COORD_Y, canvasY + offsetStartY).setDuration(INSTANT);
    ObjectAnimator moveX = ObjectAnimator.ofFloat(view, COORD_X, canvasX + offsetEndX).setDuration(1000);
    ObjectAnimator moveY = ObjectAnimator.ofFloat(view, COORD_Y, canvasY + offsetEndY).setDuration(1000);
    moveX.setStartDelay(1000);
    moveY.setStartDelay(1000);
    ObjectAnimator alphaOut = ObjectAnimator.ofFloat(view, ALPHA, INVISIBLE).setDuration(500);
    alphaOut.setStartDelay(2500);
    AnimatorSet as = new AnimatorSet();
    as.play(setUpX).with(setUpY).before(alphaIn).before(moveX).with(moveY).before(alphaOut);
    Handler handler = new Handler();
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            listener.onAnimationEnd();
        }
    };
    handler.postDelayed(runnable, 3000);
    return as;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Handler(android.os.Handler) AnimatorSet(android.animation.AnimatorSet)

Example 33 with ObjectAnimator

use of android.animation.ObjectAnimator in project weiciyuan by qii.

the class AnimationUtils method createFadeInAnimation.

public static ObjectAnimator createFadeInAnimation(Object target, int duration, final AnimationStartListener listener) {
    ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, INVISIBLE, VISIBLE);
    oa.setDuration(duration).addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
            listener.onAnimationStart();
        }

        @Override
        public void onAnimationEnd(Animator animator) {
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    return oa;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator)

Example 34 with ObjectAnimator

use of android.animation.ObjectAnimator in project weiciyuan by qii.

the class AnimationUtils method createFadeOutAnimation.

public static ObjectAnimator createFadeOutAnimation(Object target, int duration, final AnimationEndListener listener) {
    ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, INVISIBLE);
    oa.setDuration(duration).addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animator) {
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            listener.onAnimationEnd();
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    return oa;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator)

Example 35 with ObjectAnimator

use of android.animation.ObjectAnimator in project weiciyuan by qii.

the class PointAnimator method ofPoints.

public static Animator ofPoints(Object object, String xMethod, String yMethod, Point... values) {
    AnimatorSet set = new AnimatorSet();
    int[] xValues = new int[values.length];
    int[] yValues = new int[values.length];
    for (int i = 0; i < values.length; i++) {
        xValues[i] = values[i].x;
        yValues[i] = values[i].y;
    }
    ObjectAnimator xAnimator = ObjectAnimator.ofInt(object, xMethod, xValues);
    ObjectAnimator yAnimator = ObjectAnimator.ofInt(object, yMethod, yValues);
    set.playTogether(xAnimator, yAnimator);
    return set;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) Point(android.graphics.Point)

Aggregations

ObjectAnimator (android.animation.ObjectAnimator)790 Animator (android.animation.Animator)313 AnimatorSet (android.animation.AnimatorSet)214 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)208 PropertyValuesHolder (android.animation.PropertyValuesHolder)128 ValueAnimator (android.animation.ValueAnimator)111 View (android.view.View)101 Paint (android.graphics.Paint)68 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)48 TextView (android.widget.TextView)48 ViewGroup (android.view.ViewGroup)45 Rect (android.graphics.Rect)35 LinearInterpolator (android.view.animation.LinearInterpolator)35 ImageView (android.widget.ImageView)31 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)30 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)29 OvershootInterpolator (android.view.animation.OvershootInterpolator)28 ArrayList (java.util.ArrayList)22 TargetApi (android.annotation.TargetApi)21 Interpolator (android.view.animation.Interpolator)20