Search in sources :

Example 11 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project BottomBar by roughike.

the class BottomBarTab method animateColors.

private void animateColors(int previousColor, int color) {
    ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(previousColor, color);
    anim.setEvaluator(new ArgbEvaluator());
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            setColors((Integer) valueAnimator.getAnimatedValue());
        }
    });
    anim.setDuration(150);
    anim.start();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Example 12 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project android-app by spark.

the class Pin method animateYourself.

public void animateYourself() {
    final ViewGroup parent = (ViewGroup) view.getParent();
    if (pinBackgroundAnim != null) {
        pinBackgroundAnim.end();
        pinBackgroundAnim = null;
    }
    pinBackgroundAnim = (ObjectAnimator) AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_start);
    pinBackgroundAnim.setTarget(parent);
    pinBackgroundAnim.setEvaluator(new ArgbEvaluator());
    pinBackgroundAnim.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        // NO OP
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            endAnimation = getCancelAnimator();
            endAnimation.start();
        }
    });
    pinBackgroundAnim.start();
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ViewGroup(android.view.ViewGroup) ArgbEvaluator(android.animation.ArgbEvaluator)

Example 13 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project boilerplate by koush.

the class DrawerActivity method resetDrawerToggle.

private void resetDrawerToggle() {
    getDrawer().setDrawerListener(drawerToggle = new ActionBarDrawerToggle(this, getDrawer(), getDrawerOpenString(), getDrawerCloseString()) {

        //            DecelerateInterpolator interpolator = new DecelerateInterpolator();
        ArgbEvaluator evaluator = new ArgbEvaluator();

        boolean hasOpened;

        int originalStatusBarColor;

        @Override
        public void onDrawerStateChanged(int newState) {
            super.onDrawerStateChanged(newState);
            if (newState == DrawerLayout.STATE_DRAGGING && !hasOpened) {
                hasOpened = true;
                originalStatusBarColor = WindowChromeUtils.getStatusBarColor(getWindow());
            }
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
            // and don't erroneously translate this stuff.
            if (!getDrawer().isDrawerVisible(Gravity.LEFT))
                return;
            //                View content = getDrawer().getChildAt(0);
            //                View drawer = getDrawer().getChildAt(1);
            //                content.setTranslationX(Math.min(content.getMeasuredWidth(), drawer.getMeasuredWidth()) / 3 * interpolator.getInterpolation(slideOffset));
            onDrawerOpen();
            if (hasOpened)
                WindowChromeUtils.setStatusBarColor(getWindow(), (int) evaluator.evaluate(slideOffset, originalStatusBarColor, 0x4D000000));
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (hasOpened) {
                WindowChromeUtils.setStatusBarColor(getWindow(), originalStatusBarColor);
            }
            if (isFinishing())
                return;
            DrawerActivity.this.onDrawerClosed();
        }
    });
    drawerToggle.syncState();
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) View(android.view.View)

Example 14 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project boilerplate by koush.

the class ScrollingToolbarLayout method toolbarFadeToColor.

void toolbarFadeToColor(int color) {
    if (existingToolbarColorAnimation != null)
        existingToolbarColorAnimation.cancel();
    View toolbarContainer = getChildAt(getChildCount() - 1);
    int existingColor = ((ColorDrawable) toolbarContainer.getBackground()).getColor();
    existingToolbarColorAnimation = ObjectAnimator.ofInt(toolbarContainer, "backgroundColor", existingColor, color);
    existingToolbarColorAnimation.setEvaluator(new ArgbEvaluator());
    existingToolbarColorAnimation.setDuration(500);
    existingToolbarColorAnimation.start();
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ArgbEvaluator(android.animation.ArgbEvaluator) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) IHeaderRecyclerView(com.koushikdutta.boilerplate.recyclerview.IHeaderRecyclerView)

Example 15 with ArgbEvaluator

use of android.animation.ArgbEvaluator in project Rutgers-Course-Tracker by tevjef.

the class SectionInfoFragment method showSectionTracked.

@Override
public void showSectionTracked(boolean sectionIsAdded, boolean shouldAnimateView) {
    final int COLOR = ContextCompat.getColor(getParentActivity(), R.color.accent);
    final int COLOR_DARK = ContextCompat.getColor(getParentActivity(), R.color.accent_dark);
    final int ROTATION_NORMAL = 0;
    final int ROTATION_ADDED = 225;
    final int DURATION = 500;
    if (shouldAnimateView) {
        if (sectionIsAdded != mViewState.isSectionAdded) {
            ViewCompat.animate(mFab).setDuration(DURATION).setInterpolator(new DecelerateInterpolator()).rotation(sectionIsAdded ? ROTATION_ADDED : ROTATION_NORMAL);
            //I would much prefer to animate from the current coolor to the next but the fab has
            // no method to get the current color and I'm not desparate enough to manage it myself.
            // As for now, the fab will only animate on user click. Not from a db update.
            ValueAnimator colorAnim = ObjectAnimator.ofInt(this, "backgroundColor", sectionIsAdded ? COLOR : COLOR_DARK, sectionIsAdded ? COLOR_DARK : COLOR);
            colorAnim.setDuration(500);
            colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    if (mFab != null)
                        mFab.setBackgroundTintList(ColorStateList.valueOf((Integer) animation.getAnimatedValue()));
                }
            });
            colorAnim.setEvaluator(new ArgbEvaluator());
            colorAnim.start();
        }
    } else {
        //Using ViewCompat to set the tint list is bugged on pre lollipop.
        mFab.setBackgroundTintList(ColorStateList.valueOf(sectionIsAdded ? COLOR_DARK : COLOR));
        ViewCompat.setRotation(mFab, sectionIsAdded ? ROTATION_ADDED : ROTATION_NORMAL);
    }
    mViewState.isSectionAdded = sectionIsAdded;
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ArgbEvaluator(android.animation.ArgbEvaluator) ValueAnimator(android.animation.ValueAnimator)

Aggregations

ArgbEvaluator (android.animation.ArgbEvaluator)58 ValueAnimator (android.animation.ValueAnimator)28 ObjectAnimator (android.animation.ObjectAnimator)18 Animator (android.animation.Animator)10 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)7 TargetApi (android.annotation.TargetApi)6 View (android.view.View)6 Paint (android.graphics.Paint)5 AnimatorUpdateListener (android.animation.ValueAnimator.AnimatorUpdateListener)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)4 TextView (android.widget.TextView)4 SuppressLint (android.annotation.SuppressLint)3 ViewGroup (android.view.ViewGroup)3 AnimatorListener (android.animation.Animator.AnimatorListener)2 AnimatorSet (android.animation.AnimatorSet)2 PropertyValuesHolder (android.animation.PropertyValuesHolder)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 Toolbar (android.support.v7.widget.Toolbar)2