Search in sources :

Example 71 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project UltimateAndroid by cymcsg.

the class AnimationDetailFragment method doAnimation.

/**
     * This method performs the various animations available in the
     * AndroidAnimator library.
     */
private void doAnimation() {
    switch(mItem.id) {
        case 1:
            new BlindAnimation(card).animate();
            break;
        case 2:
            new BlinkAnimation(card).setListener(new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    mPlayView.setVisibility(View.VISIBLE);
                }
            }).animate();
            break;
        case 3:
            new BounceAnimation(card).setNumOfBounces(3).setDuration(Animation.DURATION_SHORT).setListener(new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    mPlayView.setVisibility(View.VISIBLE);
                }
            }).animate();
            break;
        case 4:
            new ExplodeAnimation(card).animate();
            break;
        case 5:
            new FadeInAnimation(card).animate();
            break;
        case 6:
            new FadeOutAnimation(card).animate();
            break;
        case 7:
            new FlipHorizontalAnimation(card).setListener(new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    mPlayView.setVisibility(View.VISIBLE);
                }
            }).animate();
            break;
        case 8:
            new FlipHorizontalToAnimation(card).setFlipToView(card2).setInterpolator(new LinearInterpolator()).animate();
            break;
        case 9:
            new FlipVerticalAnimation(card).setListener(new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    mPlayView.setVisibility(View.VISIBLE);
                }
            }).animate();
            break;
        case 10:
            new FlipVerticalToAnimation(card).setFlipToView(card2).setInterpolator(new LinearInterpolator()).animate();
            break;
        case 11:
            card2.setVisibility(View.VISIBLE);
            new UnfoldAnimation(card).setNumOfFolds(10).setDuration(1000).setOrientation(Orientation.HORIZONTAL).animate();
            break;
        case 12:
            card2.setVisibility(View.VISIBLE);
            new FoldAnimation(card).setNumOfFolds(10).setDuration(1000).setOrientation(Orientation.VERTICAL).animate();
            break;
        case 13:
            new HighlightAnimation(card).setListener(new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    mPlayView.setVisibility(View.VISIBLE);
                }
            }).animate();
            break;
        case 14:
            ArrayList<Point> points = new ArrayList<>();
            points.add(new Point(0, 100));
            points.add(new Point(50, 0));
            points.add(new Point(100, 100));
            points.add(new Point(0, 50));
            points.add(new Point(100, 50));
            points.add(new Point(0, 100));
            points.add(new Point(50, 50));
            new PathAnimation(card).setPoints(points).setDuration(2000).setListener(new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    mPlayView.setVisibility(View.VISIBLE);
                }
            }).animate();
            break;
        case 15:
            new PuffInAnimation(card).animate();
            break;
        case 16:
            new PuffOutAnimation(card).animate();
            break;
        case 17:
            new RotationAnimation(card).setPivot(RotationAnimation.PIVOT_TOP_LEFT).setListener(new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    mPlayView.setVisibility(View.VISIBLE);
                }
            }).animate();
            break;
        case 18:
            new ScaleInAnimation(card).animate();
            break;
        case 19:
            new ScaleOutAnimation(card).animate();
            break;
        case 20:
            new ShakeAnimation(card).setNumOfShakes(3).setDuration(Animation.DURATION_SHORT).setListener(new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    mPlayView.setVisibility(View.VISIBLE);
                }
            }).animate();
            break;
        case 21:
            new SlideInAnimation(card).setDirection(Animation.DIRECTION_UP).animate();
            break;
        case 22:
            new SlideInUnderneathAnimation(card).setDirection(Animation.DIRECTION_DOWN).animate();
            break;
        case 23:
            new SlideOutAnimation(card).setDirection(Animation.DIRECTION_LEFT).animate();
            break;
        case 24:
            new SlideOutUnderneathAnimation(card).setDirection(Animation.DIRECTION_RIGHT).animate();
            break;
        case 25:
            new TransferAnimation(card).setDestinationView(target).animate();
            break;
        case 26:
            card.setImageResource(R.drawable.test_back2);
            final AnimationListener explodeAnimListener = new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    card.setVisibility(View.INVISIBLE);
                    mPlayView.setVisibility(View.VISIBLE);
                }
            };
            final AnimationListener bounceAnimListener = new AnimationListener() {

                @Override
                public void onAnimationEnd(Animation animation) {
                    new ExplodeAnimation(card2).setListener(explodeAnimListener).animate();
                }
            };
            final ParallelAnimatorListener slideFadeInAnimListener = new ParallelAnimatorListener() {

                @Override
                public void onAnimationEnd(ParallelAnimator parallelAnimator) {
                    BounceAnimation bounceAnim = new BounceAnimation(card2);
                    bounceAnim.setNumOfBounces(10);
                    bounceAnim.setListener(bounceAnimListener);
                    bounceAnim.animate();
                }
            };
            final ParallelAnimatorListener slideFadeOutAnimListener = new ParallelAnimatorListener() {

                @Override
                public void onAnimationEnd(ParallelAnimator parallelAnimator) {
                    ParallelAnimator slideFadeInAnim = new ParallelAnimator();
                    slideFadeInAnim.add(new SlideInAnimation(card2).setDirection(Animation.DIRECTION_RIGHT));
                    slideFadeInAnim.add(new FadeInAnimation(card2));
                    slideFadeInAnim.setDuration(1000);
                    slideFadeInAnim.setListener(slideFadeInAnimListener);
                    slideFadeInAnim.animate();
                }
            };
            final ParallelAnimatorListener rotatePathAnimListener = new ParallelAnimatorListener() {

                @Override
                public void onAnimationEnd(ParallelAnimator parallelAnimator) {
                    ParallelAnimator slideFadeOutAnim = new ParallelAnimator();
                    slideFadeOutAnim.add(new SlideOutAnimation(card).setDirection(Animation.DIRECTION_RIGHT));
                    slideFadeOutAnim.add(new FadeOutAnimation(card));
                    slideFadeOutAnim.setInterpolator(new LinearInterpolator());
                    slideFadeOutAnim.setDuration(1000);
                    slideFadeOutAnim.setListener(slideFadeOutAnimListener);
                    slideFadeOutAnim.animate();
                }
            };
            final ParallelAnimatorListener scaleFlipAnimListener = new ParallelAnimatorListener() {

                @Override
                public void onAnimationEnd(ParallelAnimator parallelAnimator) {
                    ArrayList<Point> parallelPoints = new ArrayList<>();
                    parallelPoints.add(new Point(50, 0));
                    parallelPoints.add(new Point(100, 50));
                    parallelPoints.add(new Point(50, 100));
                    parallelPoints.add(new Point(0, 50));
                    parallelPoints.add(new Point(50, 50));
                    ParallelAnimator rotatePathAnim = new ParallelAnimator();
                    rotatePathAnim.add(new PathAnimation(card).setPoints(parallelPoints));
                    rotatePathAnim.add(new RotationAnimation(card));
                    rotatePathAnim.setInterpolator(new LinearInterpolator());
                    rotatePathAnim.setDuration(2000);
                    rotatePathAnim.setListener(rotatePathAnimListener);
                    rotatePathAnim.animate();
                }
            };
            ParallelAnimator scaleFlipAnim = new ParallelAnimator();
            scaleFlipAnim.add(new ScaleInAnimation(card));
            scaleFlipAnim.add(new FlipHorizontalAnimation(card));
            scaleFlipAnim.add(new FlipVerticalAnimation(card));
            scaleFlipAnim.setDuration(2000);
            scaleFlipAnim.setListener(scaleFlipAnimListener);
            scaleFlipAnim.animate();
            break;
        default:
            break;
    }
}
Also used : FoldAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FoldAnimation) UnfoldAnimation(com.marshalchen.common.uimodule.easyandroidanimations.UnfoldAnimation) FlipHorizontalAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FlipHorizontalAnimation) FadeOutAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FadeOutAnimation) BounceAnimation(com.marshalchen.common.uimodule.easyandroidanimations.BounceAnimation) ArrayList(java.util.ArrayList) HighlightAnimation(com.marshalchen.common.uimodule.easyandroidanimations.HighlightAnimation) SlideInUnderneathAnimation(com.marshalchen.common.uimodule.easyandroidanimations.SlideInUnderneathAnimation) BlinkAnimation(com.marshalchen.common.uimodule.easyandroidanimations.BlinkAnimation) FlipVerticalToAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FlipVerticalToAnimation) FadeInAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FadeInAnimation) FlipHorizontalToAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FlipHorizontalToAnimation) ParallelAnimatorListener(com.marshalchen.common.uimodule.easyandroidanimations.ParallelAnimatorListener) ShakeAnimation(com.marshalchen.common.uimodule.easyandroidanimations.ShakeAnimation) RotationAnimation(com.marshalchen.common.uimodule.easyandroidanimations.RotationAnimation) TransferAnimation(com.marshalchen.common.uimodule.easyandroidanimations.TransferAnimation) PathAnimation(com.marshalchen.common.uimodule.easyandroidanimations.PathAnimation) Point(android.graphics.Point) BlindAnimation(com.marshalchen.common.uimodule.easyandroidanimations.BlindAnimation) SlideOutAnimation(com.marshalchen.common.uimodule.easyandroidanimations.SlideOutAnimation) ExplodeAnimation(com.marshalchen.common.uimodule.easyandroidanimations.ExplodeAnimation) FlipVerticalAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FlipVerticalAnimation) ParallelAnimator(com.marshalchen.common.uimodule.easyandroidanimations.ParallelAnimator) LinearInterpolator(android.view.animation.LinearInterpolator) SlideInAnimation(com.marshalchen.common.uimodule.easyandroidanimations.SlideInAnimation) PuffInAnimation(com.marshalchen.common.uimodule.easyandroidanimations.PuffInAnimation) PuffOutAnimation(com.marshalchen.common.uimodule.easyandroidanimations.PuffOutAnimation) SlideOutUnderneathAnimation(com.marshalchen.common.uimodule.easyandroidanimations.SlideOutUnderneathAnimation) FadeInAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FadeInAnimation) FadeOutAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FadeOutAnimation) ShakeAnimation(com.marshalchen.common.uimodule.easyandroidanimations.ShakeAnimation) SlideInUnderneathAnimation(com.marshalchen.common.uimodule.easyandroidanimations.SlideInUnderneathAnimation) ScaleOutAnimation(com.marshalchen.common.uimodule.easyandroidanimations.ScaleOutAnimation) UnfoldAnimation(com.marshalchen.common.uimodule.easyandroidanimations.UnfoldAnimation) BounceAnimation(com.marshalchen.common.uimodule.easyandroidanimations.BounceAnimation) HighlightAnimation(com.marshalchen.common.uimodule.easyandroidanimations.HighlightAnimation) RotationAnimation(com.marshalchen.common.uimodule.easyandroidanimations.RotationAnimation) FlipHorizontalAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FlipHorizontalAnimation) PuffOutAnimation(com.marshalchen.common.uimodule.easyandroidanimations.PuffOutAnimation) ScaleInAnimation(com.marshalchen.common.uimodule.easyandroidanimations.ScaleInAnimation) BlindAnimation(com.marshalchen.common.uimodule.easyandroidanimations.BlindAnimation) FoldAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FoldAnimation) SlideInAnimation(com.marshalchen.common.uimodule.easyandroidanimations.SlideInAnimation) SlideOutAnimation(com.marshalchen.common.uimodule.easyandroidanimations.SlideOutAnimation) PuffInAnimation(com.marshalchen.common.uimodule.easyandroidanimations.PuffInAnimation) FlipVerticalAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FlipVerticalAnimation) TransferAnimation(com.marshalchen.common.uimodule.easyandroidanimations.TransferAnimation) FlipVerticalToAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FlipVerticalToAnimation) PathAnimation(com.marshalchen.common.uimodule.easyandroidanimations.PathAnimation) BlinkAnimation(com.marshalchen.common.uimodule.easyandroidanimations.BlinkAnimation) Animation(com.marshalchen.common.uimodule.easyandroidanimations.Animation) ExplodeAnimation(com.marshalchen.common.uimodule.easyandroidanimations.ExplodeAnimation) SlideOutUnderneathAnimation(com.marshalchen.common.uimodule.easyandroidanimations.SlideOutUnderneathAnimation) FlipHorizontalToAnimation(com.marshalchen.common.uimodule.easyandroidanimations.FlipHorizontalToAnimation) ScaleInAnimation(com.marshalchen.common.uimodule.easyandroidanimations.ScaleInAnimation) AnimationListener(com.marshalchen.common.uimodule.easyandroidanimations.AnimationListener) ScaleOutAnimation(com.marshalchen.common.uimodule.easyandroidanimations.ScaleOutAnimation)

Example 72 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project UltimateAndroid by cymcsg.

the class PullToRefreshView method init.

/**
     * init
     *
     * @param
     * @description
     */
private void init() {
    // Load all of the animations we need in code rather than through XML
    mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(250);
    mFlipAnimation.setFillAfter(true);
    mReverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(250);
    mReverseFlipAnimation.setFillAfter(true);
    mInflater = LayoutInflater.from(getContext());
    // header view 在此添加,保证是第一个添加到linearlayout的最上端
    addHeaderView();
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) LinearInterpolator(android.view.animation.LinearInterpolator)

Example 73 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project UltimateAndroid by cymcsg.

the class ArcLayout method createShrinkAnimation.

private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, long startOffset, long duration, Interpolator interpolator) {
    AnimationSet animationSet = new AnimationSet(false);
    animationSet.setFillAfter(true);
    final long preDuration = duration / 2;
    Animation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setStartOffset(startOffset);
    rotateAnimation.setDuration(preDuration);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    rotateAnimation.setFillAfter(true);
    animationSet.addAnimation(rotateAnimation);
    Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720);
    translateAnimation.setStartOffset(startOffset + preDuration);
    translateAnimation.setDuration(duration - preDuration);
    translateAnimation.setInterpolator(interpolator);
    translateAnimation.setFillAfter(true);
    animationSet.addAnimation(translateAnimation);
    return animationSet;
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) LinearInterpolator(android.view.animation.LinearInterpolator) RotateAnimation(android.view.animation.RotateAnimation) Animation(android.view.animation.Animation) AnimationSet(android.view.animation.AnimationSet)

Example 74 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project AVLoadingIndicatorView by 81813780.

the class BallZigZagDeflectIndicator method onCreateAnimators.

@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
    ArrayList<ValueAnimator> animators = new ArrayList<>();
    float startX = getWidth() / 6;
    float startY = getWidth() / 6;
    for (int i = 0; i < 2; i++) {
        final int index = i;
        ValueAnimator translateXAnim = ValueAnimator.ofFloat(startX, getWidth() - startX, startX, getWidth() - startX, startX);
        if (i == 1) {
            translateXAnim = ValueAnimator.ofFloat(getWidth() - startX, startX, getWidth() - startX, startX, getWidth() - startX);
        }
        ValueAnimator translateYAnim = ValueAnimator.ofFloat(startY, startY, getHeight() - startY, getHeight() - startY, startY);
        if (i == 1) {
            translateYAnim = ValueAnimator.ofFloat(getHeight() - startY, getHeight() - startY, startY, startY, getHeight() - startY);
        }
        translateXAnim.setDuration(2000);
        translateXAnim.setInterpolator(new LinearInterpolator());
        translateXAnim.setRepeatCount(-1);
        addUpdateListener(translateXAnim, new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                translateX[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        translateYAnim.setDuration(2000);
        translateYAnim.setInterpolator(new LinearInterpolator());
        translateYAnim.setRepeatCount(-1);
        addUpdateListener(translateYAnim, new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                translateY[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        animators.add(translateXAnim);
        animators.add(translateYAnim);
    }
    return animators;
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ArrayList(java.util.ArrayList) ValueAnimator(android.animation.ValueAnimator)

Example 75 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project AVLoadingIndicatorView by 81813780.

the class BallZigZagIndicator method onCreateAnimators.

@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
    ArrayList<ValueAnimator> animators = new ArrayList<>();
    float startX = getWidth() / 6;
    float startY = getWidth() / 6;
    for (int i = 0; i < 2; i++) {
        final int index = i;
        ValueAnimator translateXAnim = ValueAnimator.ofFloat(startX, getWidth() - startX, getWidth() / 2, startX);
        if (i == 1) {
            translateXAnim = ValueAnimator.ofFloat(getWidth() - startX, startX, getWidth() / 2, getWidth() - startX);
        }
        ValueAnimator translateYAnim = ValueAnimator.ofFloat(startY, startY, getHeight() / 2, startY);
        if (i == 1) {
            translateYAnim = ValueAnimator.ofFloat(getHeight() - startY, getHeight() - startY, getHeight() / 2, getHeight() - startY);
        }
        translateXAnim.setDuration(1000);
        translateXAnim.setInterpolator(new LinearInterpolator());
        translateXAnim.setRepeatCount(-1);
        addUpdateListener(translateXAnim, new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                translateX[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        translateYAnim.setDuration(1000);
        translateYAnim.setInterpolator(new LinearInterpolator());
        translateYAnim.setRepeatCount(-1);
        addUpdateListener(translateYAnim, new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                translateY[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        animators.add(translateXAnim);
        animators.add(translateYAnim);
    }
    return animators;
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) ArrayList(java.util.ArrayList) ValueAnimator(android.animation.ValueAnimator) Paint(android.graphics.Paint)

Aggregations

LinearInterpolator (android.view.animation.LinearInterpolator)217 ValueAnimator (android.animation.ValueAnimator)65 Animator (android.animation.Animator)42 ObjectAnimator (android.animation.ObjectAnimator)39 Paint (android.graphics.Paint)30 ArrayList (java.util.ArrayList)28 AlphaAnimation (android.view.animation.AlphaAnimation)27 RotateAnimation (android.view.animation.RotateAnimation)24 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)22 PropertyValuesHolder (android.animation.PropertyValuesHolder)18 Animatable (android.graphics.drawable.Animatable)17 View (android.view.View)17 Animation (android.view.animation.Animation)17 Transformation (android.view.animation.Transformation)17 AnimatorSet (android.animation.AnimatorSet)14 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)12 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)11 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)9 AnimationListener (android.view.animation.Animation.AnimationListener)8