Search in sources :

Example 76 with Animator

use of android.animation.Animator in project JJSearchViewAnim by android-cjj.

the class JJBaseController method startSearchViewAnim.

public ValueAnimator startSearchViewAnim(float startF, float endF, long time, final PathMeasure pathMeasure) {
    ValueAnimator valueAnimator = ValueAnimator.ofFloat(startF, endF);
    valueAnimator.setDuration(time);
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mPro = (float) valueAnimator.getAnimatedValue();
            if (null != pathMeasure)
                pathMeasure.getPosTan(mPro, mPos, null);
            getSearchView().invalidate();
        }
    });
    valueAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
        }
    });
    if (!valueAnimator.isRunning()) {
        valueAnimator.start();
    }
    mPro = 0;
    return valueAnimator;
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) LinearInterpolator(android.view.animation.LinearInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ValueAnimator(android.animation.ValueAnimator)

Example 77 with Animator

use of android.animation.Animator in project plaid by nickbutcher.

the class DesignerNewsStory method doFabExpand.

private void doFabExpand() {
    // translate the chrome placeholder ui so that it is centered on the FAB
    int fabCenterX = (fab.getLeft() + fab.getRight()) / 2;
    int fabCenterY = ((fab.getTop() + fab.getBottom()) / 2) - fabExpand.getTop();
    int translateX = fabCenterX - (fabExpand.getWidth() / 2);
    int translateY = fabCenterY - (fabExpand.getHeight() / 2);
    fabExpand.setTranslationX(translateX);
    fabExpand.setTranslationY(translateY);
    // then reveal the placeholder ui, starting from the center & same dimens as fab
    fabExpand.setVisibility(View.VISIBLE);
    Animator reveal = ViewAnimationUtils.createCircularReveal(fabExpand, fabExpand.getWidth() / 2, fabExpand.getHeight() / 2, fab.getWidth() / 2, (int) Math.hypot(fabExpand.getWidth() / 2, fabExpand.getHeight() / 2)).setDuration(fabExpandDuration);
    // translate the placeholder ui back into position along an arc
    GravityArcMotion arcMotion = new GravityArcMotion();
    arcMotion.setMinimumVerticalAngle(70f);
    Path motionPath = arcMotion.getPath(translateX, translateY, 0, 0);
    Animator position = ObjectAnimator.ofFloat(fabExpand, View.TRANSLATION_X, View.TRANSLATION_Y, motionPath).setDuration(fabExpandDuration);
    // animate from the FAB colour to the placeholder background color
    Animator background = ObjectAnimator.ofArgb(fabExpand, ViewUtils.BACKGROUND_COLOR, ContextCompat.getColor(this, R.color.designer_news), ContextCompat.getColor(this, R.color.background_light)).setDuration(fabExpandDuration);
    // fade out the fab (rapidly)
    Animator fadeOutFab = ObjectAnimator.ofFloat(fab, View.ALPHA, 0f).setDuration(60);
    // play 'em all together with the material interpolator
    AnimatorSet show = new AnimatorSet();
    show.setInterpolator(getFastOutSlowInInterpolator(DesignerNewsStory.this));
    show.playTogether(reveal, background, position, fadeOutFab);
    show.start();
}
Also used : Path(android.graphics.Path) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) SlideInItemAnimator(io.plaidapp.ui.recyclerview.SlideInItemAnimator) GravityArcMotion(io.plaidapp.ui.transitions.GravityArcMotion) AnimatorSet(android.animation.AnimatorSet)

Example 78 with Animator

use of android.animation.Animator in project android-demos by novoda.

the class VisibilityController method setVisible.

boolean setVisible(final boolean visible, boolean animated) {
    if (isVisible() == visible) {
        return false;
    }
    mVisible = visible;
    if (animated) {
        float toAlpha = visible ? 1.0f : 0.0f;
        ObjectAnimator mAnimator = ObjectAnimator.ofFloat(mView, "Alpha", 1 - toAlpha, toAlpha);
        mAnimator.setDuration(mAnimationDuration).addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animator) {
                if (visible) {
                    setViewVisible(true);
                }
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                if (!visible) {
                    setViewVisible(false);
                }
            }
        });
        mAnimator.start();
    } else {
        setViewVisible(visible);
    }
    return true;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter)

Example 79 with Animator

use of android.animation.Animator 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 80 with Animator

use of android.animation.Animator 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)

Aggregations

Animator (android.animation.Animator)1413 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)868 ObjectAnimator (android.animation.ObjectAnimator)724 ValueAnimator (android.animation.ValueAnimator)630 AnimatorSet (android.animation.AnimatorSet)285 View (android.view.View)230 ViewGroup (android.view.ViewGroup)110 ArrayList (java.util.ArrayList)104 PropertyValuesHolder (android.animation.PropertyValuesHolder)96 Paint (android.graphics.Paint)79 StackStateAnimator (com.android.systemui.statusbar.stack.StackStateAnimator)75 ImageView (android.widget.ImageView)68 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)67 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)65 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)64 TextView (android.widget.TextView)61 RenderNodeAnimator (android.view.RenderNodeAnimator)51 ViewPropertyAnimator (android.view.ViewPropertyAnimator)51 Rect (android.graphics.Rect)50 Interpolator (android.view.animation.Interpolator)49