Example usage for android.animation ValueAnimator addUpdateListener

List of usage examples for android.animation ValueAnimator addUpdateListener

Introduction

In this page you can find the example usage for android.animation ValueAnimator addUpdateListener.

Prototype

public void addUpdateListener(AnimatorUpdateListener listener) 

Source Link

Document

Adds a listener to the set of listeners that are sent update events through the life of an animation.

Usage

From source file:org.mythtv.client.ui.BackendStatusFragment.java

private void animateCardLinearLayout(final LinearLayout linearLayout, long startDelay) {
    linearLayout.setAlpha(1);//from w  w w  . j a  v a2s.  c  om

    // animator that translates linearlayout
    AnimatorUpdateListener translationAnimatorListener = new AnimatorUpdateListener() {

        /* (non-Javadoc)
         * @see android.animation.ValueAnimator.AnimatorUpdateListener#onAnimationUpdate(android.animation.ValueAnimator)
         */
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            Float w = (Float) animation.getAnimatedValue();
            linearLayout.setTranslationY(w);
        }

    };

    ValueAnimator scaleAnimator = ValueAnimator.ofFloat(linearLayout.getTranslationY(), 0f);
    scaleAnimator.setDuration(500);
    scaleAnimator.setRepeatCount(0);
    scaleAnimator.setStartDelay(startDelay);
    scaleAnimator.addUpdateListener(translationAnimatorListener);

    scaleAnimator.start();
}

From source file:com.nihaskalam.progressbuttonlibrary.CircularProgressButton.java

private void animateIdleStateButtonAfterClick() {
    int textColorChangeDuration = 10;
    ObjectAnimator colorAnim = ObjectAnimator.ofInt(this, "textColor", getNormalColor(this.getTextColors()),
            mIdleStateTextColorAfterClick);
    colorAnim.setDuration(textColorChangeDuration);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.start();// w ww.j a  v a  2  s.  c  o m

    ObjectAnimator colorAnim1 = ObjectAnimator.ofInt(this, "textColor", mIdleStateTextColorAfterClick,
            getNormalColor(this.getTextColors()));
    colorAnim1.setDuration(0);
    colorAnim1.setStartDelay(IDLE_STATE_ANIMATION_DURATION_AFTER_CLICK - textColorChangeDuration);
    colorAnim1.setEvaluator(new ArgbEvaluator());
    colorAnim1.setInterpolator(new BounceInterpolator());
    colorAnim1.start();

    ObjectAnimator bgAnim = ObjectAnimator.ofInt(this, "backgroundColor", getNormalColor(mIdleColorState),
            mIdleStateBackgroundColorAfterClick);
    bgAnim.setDuration(0);
    bgAnim.setEvaluator(new ArgbEvaluator());
    bgAnim.start();

    int textSizeAnimationDuration = 150;
    ValueAnimator animator = ValueAnimator.ofFloat(textSize, textSize - textSize / 4);
    animator.setDuration(textSizeAnimationDuration);
    animator.setRepeatCount(1);
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float animatedValue = (float) valueAnimator.getAnimatedValue();
            setTextSize(animatedValue);
        }
    });

    animator.start();
}

From source file:com.bitants.wally.activities.ImageDetailsActivity.java

/**
 * Animations animations animations.//from   ww w  .  j av  a2 s .co  m
 * @param visibility if VISIBLE, expands toolbar.
 */
private void animateToolbar(int visibility) {
    float from;
    float to;
    int toolbarOffset;
    int fabOffset;
    if (visibility == View.VISIBLE) {
        from = 0.0f;
        to = 1.0f;
        fabOffset = 200;
        toolbarOffset = 0;
    } else {
        from = 1.0f;
        to = 0.0f;
        fabOffset = 0;
        toolbarOffset = 200;
    }

    buttonFullscreen.animate().scaleX(to).scaleY(to).setDuration(400).setStartDelay(fabOffset)
            .setInterpolator(new EaseInOutBezierInterpolator()).setListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animator) {
                    buttonFullscreen.setVisibility(View.VISIBLE);
                }

                @Override
                public void onAnimationEnd(Animator animator) {

                }

                @Override
                public void onAnimationCancel(Animator animator) {

                }

                @Override
                public void onAnimationRepeat(Animator animator) {

                }
            }).start();

    int toolbarFrom;
    int toolbarTo;

    if (from > 0.0f) {
        toolbarFrom = getResources().getDimensionPixelSize(R.dimen.details_toolbar_height);
        toolbarTo = 0;
    } else {
        toolbarFrom = 0;
        toolbarTo = getResources().getDimensionPixelSize(R.dimen.details_toolbar_height);
    }

    ValueAnimator valueAnimator = ValueAnimator.ofInt(toolbarFrom, toolbarTo);
    valueAnimator.setDuration(400);
    valueAnimator.setStartDelay(toolbarOffset);
    valueAnimator.setInterpolator(new EaseInOutBezierInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            RelativeLayout.LayoutParams toolbarParams = (RelativeLayout.LayoutParams) toolbar.getLayoutParams();
            toolbarParams.height = val;
            toolbar.setLayoutParams(toolbarParams);
        }
    });
    valueAnimator.start();

}

From source file:com.songcode.materialnotes.ui.NoteEditActivity.java

private void animateRevealHide(final View targetview, View startView) {
    if (isActionInsertOrEdit()) {
        int cx = startView.getLeft() + (startView.getWidth() / 2); //middle of button
        int cy = startView.getTop() + (startView.getHeight() / 2); //middle of button
        int radius = (int) Math.sqrt(Math.pow(cx, 2) + Math.pow(cy, 2)); //hypotenuse to top left

        Animator anim = ViewAnimationUtils.createCircularReveal(targetview, cx, cy, radius, 0);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override/*w w w .  j  av  a 2 s. c om*/
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                targetview.setVisibility(View.INVISIBLE);
            }
        });
        //anim.setInterpolator(new AccelerateInterpolator());
        anim.setDuration(ANIM_DURATION);
        anim.start();

        Integer colorTo = getResources().getColor(R.color.primaryColor);
        Integer colorFrom = getResources().getColor(android.R.color.white);
        ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
        colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                targetview.setBackgroundColor((Integer) animator.getAnimatedValue());
            }

        });
        colorAnimation.setInterpolator(new AccelerateInterpolator(2));
        colorAnimation.setDuration(ANIM_DURATION);
        colorAnimation.start();
    } else if (isActionActionView()) {
        mAnimBackGroudView.animate().scaleX(1).scaleY(1).alpha(1).translationY(0).setDuration(ANIM_DURATION)
                .setInterpolator(new AccelerateInterpolator()).start();
        mNoteEditor.animate().alpha(0).setDuration(100).start();
    }
}

From source file:com.bitants.wally.activities.ImageDetailsActivity.java

/**
 * Animations animations animations.//from  w w w  .j a v a  2 s .  c o  m
 */
private void toggleZoomImage() {

    int animationDuration = 400;

    if (isInFullscreen()) {
        scrollView.smoothScrollTo(0, (Integer) scrollView.getTag());
        if (photoViewAttacher != null) {
            photoViewAttacher.cleanup();
            photoViewAttacher = null;
            photoView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        }
    } else {
        scrollView.setTag(scrollView.getScrollY());
        scrollView.smoothScrollTo(0, 0);

        if (photoViewAttacher == null) {
            photoViewAttacher = new PhotoViewAttacher(photoView);
            photoViewAttacher.setZoomable(true);
            photoViewAttacher.setScaleType(ImageView.ScaleType.CENTER_CROP);
        }
    }

    if (getSupportActionBar() != null) {
        getToolbar().animate().translationY(isInFullscreen() ? 0.0f : -getToolbar().getMeasuredHeight())
                .alpha(isInFullscreen() ? 1.0f : 0.0f).setDuration(500)
                .setInterpolator(new EaseInOutBezierInterpolator()).start();
    }

    findViewById(R.id.image_details_protective_shadow).animate().alpha(isInFullscreen() ? 1.0f : 0.0f)
            .setDuration(500).setInterpolator(new EaseInOutBezierInterpolator()).start();

    int minimumAllowedHeight = getToolbar().getMeasuredHeight()
            + getResources().getDimensionPixelSize(R.dimen.fab_padding_positive);

    if (imageSize.getHeight() < minimumAllowedHeight) {
        int topFrom;
        int topTo;
        if (isInFullscreen()) {
            topFrom = 0;
            topTo = getToolbar().getMeasuredHeight();
        } else {
            topFrom = photoLayoutHolder.getPaddingTop();
            topTo = 0;
        }
        ValueAnimator topValueAnimator = ValueAnimator.ofInt(topFrom, topTo);
        topValueAnimator.setDuration(animationDuration);
        topValueAnimator.setInterpolator(new EaseInOutBezierInterpolator());
        topValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                int val = (Integer) valueAnimator.getAnimatedValue();
                photoLayoutHolder.setPadding(photoLayoutHolder.getPaddingLeft(), val,
                        photoLayoutHolder.getPaddingRight(), photoLayoutHolder.getPaddingBottom());
            }
        });
        topValueAnimator.start();
    }

    if (photoLayoutHolder.getTranslationY() != 0.0f) {
        photoLayoutHolder.animate().translationY(0.0f).setInterpolator(new EaseInOutBezierInterpolator())
                .setDuration(animationDuration).start();
    }

    WindowManager win = getWindowManager();
    Display d = win.getDefaultDisplay();

    int from = photoView.getMeasuredHeight();
    int to = isInFullscreen() ? imageSize.getHeight() : d.getHeight();

    ValueAnimator valueAnimator = ValueAnimator.ofInt(from, to);
    valueAnimator.setDuration(animationDuration);
    valueAnimator.setInterpolator(new EaseInOutBezierInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            RelativeLayout.LayoutParams toolbarParams = (RelativeLayout.LayoutParams) photoView
                    .getLayoutParams();
            toolbarParams.height = val;
            photoView.setLayoutParams(toolbarParams);
        }
    });
    valueAnimator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animator) {
        }

        @Override
        public void onAnimationEnd(Animator animator) {
            if (photoViewAttacher != null) {
                photoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
                    @Override
                    public void onPhotoTap(View view, float v, float v2) {
                        toggleZoomImage();
                    }
                });
            }
        }

        @Override
        public void onAnimationCancel(Animator animator) {
        }

        @Override
        public void onAnimationRepeat(Animator animator) {
        }
    });
    valueAnimator.start();

    int scrollTo = isInFullscreen() ? 0 : d.getHeight();

    scrollView.animate().y(scrollTo).setDuration(animationDuration)
            .setInterpolator(new EaseInOutBezierInterpolator()).start();

    isInFullscreen = !isInFullscreen;
}

From source file:com.android.settings.widget.DotsPageIndicator.java

private ValueAnimator createMoveSelectedAnimator(final float moveTo, int was, int now, int steps) {
    // create the actual move animator
    ValueAnimator moveSelected = ValueAnimator.ofFloat(selectedDotX, moveTo);

    // also set up a pending retreat anim  this starts when the move is 75% complete
    retreatAnimation = new PendingRetreatAnimator(was, now, steps,
            now > was ? new RightwardStartPredicate(moveTo - ((moveTo - selectedDotX) * 0.25f))
                    : new LeftwardStartPredicate(moveTo + ((selectedDotX - moveTo) * 0.25f)));

    moveSelected.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//  www. j  a v a  2 s . c om
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            // todo avoid autoboxing
            selectedDotX = (Float) valueAnimator.getAnimatedValue();
            retreatAnimation.startIfNecessary(selectedDotX);
            postInvalidateOnAnimation();
        }
    });

    moveSelected.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            // set a flag so that we continue to draw the unselected dot in the target position
            // until the selected dot has finished moving into place
            selectedDotInPosition = false;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            // set a flag when anim finishes so that we don't draw both selected & unselected
            // page dots
            selectedDotInPosition = true;
        }
    });

    // slightly delay the start to give the joins a chance to run
    // unless dot isn't in position yet  then don't delay!
    moveSelected.setStartDelay(selectedDotInPosition ? animDuration / 4L : 0L);
    moveSelected.setDuration(animDuration * 3L / 4L);
    moveSelected.setInterpolator(interpolator);
    return moveSelected;
}

From source file:org.protocoderrunner.apprunner.api.PUI.java

@ProtocoderScript
@APIMethod(description = "Resize a view to a given width and height. If a parameter is -1 then that dimension is not changed", example = "")
@APIParam(params = { "View", "width", "height" })
public void resize(final View v, int h, int w) {
    boolean animated = false;

    if (!animated) {
        if (h != -1) {
            v.getLayoutParams().height = h;
        }/*from w  ww .  ja  va  2 s .c o m*/
        if (w != -1) {
            v.getLayoutParams().width = w;
        }
        v.setLayoutParams(v.getLayoutParams());
    } else {

        int initHeight = v.getLayoutParams().height;
        // v.setLayoutParams(v.getLayoutParams());

        ValueAnimator anim = ValueAnimator.ofInt(initHeight, h);
        anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                int val = (Integer) valueAnimator.getAnimatedValue();
                v.getLayoutParams().height = val;
                v.setLayoutParams(v.getLayoutParams());

            }
        });
        anim.setDuration(200);
        anim.start();
    }
}

From source file:cw.kop.autobackground.sources.SourceListFragment.java

/**
 * Shows LocalImageFragment to view images
 *
 * @param view  source card which was selected
 * @param index position of source in listAdapter
 *//*w  ww . java2s  . c o m*/
private void showViewImageFragment(final View view, final int index) {
    sourceList.setOnItemClickListener(null);
    sourceList.setEnabled(false);

    listAdapter.saveData();
    Source item = listAdapter.getItem(index);
    String type = item.getType();
    String directory;
    if (type.equals(AppSettings.FOLDER)) {
        directory = item.getData().split(AppSettings.DATA_SPLITTER)[0];
    } else {
        directory = AppSettings.getDownloadPath() + "/" + item.getTitle() + " " + AppSettings.getImagePrefix();
    }

    Log.i(TAG, "Directory: " + directory);

    final RelativeLayout sourceContainer = (RelativeLayout) view.findViewById(R.id.source_container);
    final ImageView sourceImage = (ImageView) view.findViewById(R.id.source_image);
    final View imageOverlay = view.findViewById(R.id.source_image_overlay);
    final EditText sourceTitle = (EditText) view.findViewById(R.id.source_title);
    final ImageView deleteButton = (ImageView) view.findViewById(R.id.source_delete_button);
    final ImageView viewButton = (ImageView) view.findViewById(R.id.source_view_image_button);
    final ImageView editButton = (ImageView) view.findViewById(R.id.source_edit_button);
    final LinearLayout sourceExpandContainer = (LinearLayout) view.findViewById(R.id.source_expand_container);

    final float viewStartHeight = sourceContainer.getHeight();
    final float viewStartY = view.getY();
    final float overlayStartAlpha = imageOverlay.getAlpha();
    final float listHeight = sourceList.getHeight();
    Log.i(TAG, "listHeight: " + listHeight);
    Log.i(TAG, "viewStartHeight: " + viewStartHeight);

    final LocalImageFragment localImageFragment = new LocalImageFragment();
    Bundle arguments = new Bundle();
    arguments.putString("view_path", directory);
    localImageFragment.setArguments(arguments);

    Animation animation = new Animation() {

        private boolean needsFragment = true;

        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {

            if (needsFragment && interpolatedTime >= 1) {
                needsFragment = false;
                getFragmentManager().beginTransaction()
                        .add(R.id.content_frame, localImageFragment, "image_fragment").addToBackStack(null)
                        .setTransition(FragmentTransaction.TRANSIT_NONE).commit();
            }
            ViewGroup.LayoutParams params = sourceContainer.getLayoutParams();
            params.height = (int) (viewStartHeight + (listHeight - viewStartHeight) * interpolatedTime);
            sourceContainer.setLayoutParams(params);
            view.setY(viewStartY - interpolatedTime * viewStartY);
            deleteButton.setAlpha(1.0f - interpolatedTime);
            viewButton.setAlpha(1.0f - interpolatedTime);
            editButton.setAlpha(1.0f - interpolatedTime);
            sourceTitle.setAlpha(1.0f - interpolatedTime);
            imageOverlay.setAlpha(overlayStartAlpha - overlayStartAlpha * (1.0f - interpolatedTime));
            sourceExpandContainer.setAlpha(1.0f - interpolatedTime);
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (needsListReset) {
                Parcelable state = sourceList.onSaveInstanceState();
                sourceList.setAdapter(null);
                sourceList.setAdapter(listAdapter);
                sourceList.onRestoreInstanceState(state);
                sourceList.setOnItemClickListener(SourceListFragment.this);
                sourceList.setEnabled(true);
                needsListReset = false;
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

    ValueAnimator cardColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
            AppSettings.getDialogColor(appContext),
            getResources().getColor(AppSettings.getBackgroundColorResource()));
    cardColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            sourceContainer.setBackgroundColor((Integer) animation.getAnimatedValue());
        }

    });

    DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(1.5f);

    animation.setDuration(INFO_ANIMATION_TIME);
    cardColorAnimation.setDuration(INFO_ANIMATION_TIME);

    animation.setInterpolator(decelerateInterpolator);
    cardColorAnimation.setInterpolator(decelerateInterpolator);

    needsListReset = true;
    cardColorAnimation.start();
    view.startAnimation(animation);

}

From source file:com.commonsware.cwac.crossport.design.widget.BaseTransientBottomBar.java

private void animateViewOut(final int event) {
    if (Build.VERSION.SDK_INT >= 12) {
        final ValueAnimator animator = new ValueAnimator();
        animator.setIntValues(0, mView.getHeight());
        animator.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
        animator.setDuration(ANIMATION_DURATION);
        animator.addListener(new AnimatorListenerAdapter() {
            @Override//www . j  a v a2 s .c o m
            public void onAnimationStart(Animator animator) {
                mContentViewCallback.animateContentOut(0, ANIMATION_FADE_DURATION);
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                onViewHidden(event);
            }
        });
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            private int mPreviousAnimatedIntValue = 0;

            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                int currentAnimatedIntValue = (int) animator.getAnimatedValue();
                if (USE_OFFSET_API) {
                    ViewCompat.offsetTopAndBottom(mView, currentAnimatedIntValue - mPreviousAnimatedIntValue);
                } else {
                    mView.setTranslationY(currentAnimatedIntValue);
                }
                mPreviousAnimatedIntValue = currentAnimatedIntValue;
            }
        });
        animator.start();
    } else {
        final Animation anim = AnimationUtils.loadAnimation(mView.getContext(), R.anim.design_snackbar_out);
        anim.setInterpolator(FAST_OUT_SLOW_IN_INTERPOLATOR);
        anim.setDuration(ANIMATION_DURATION);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
                onViewHidden(event);
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
        mView.startAnimation(anim);
    }
}

From source file:cw.kop.autobackground.sources.SourceListFragment.java

@Override
public void onClick(final View v) {

    switch (v.getId()) {

    case R.id.set_button:
        setWallpaper();/*www. j a v a  2 s . c  o m*/
        break;
    case R.id.floating_button_icon:
        final GradientDrawable circleDrawable = (GradientDrawable) getResources()
                .getDrawable(R.drawable.floating_button_circle);
        final float scale = (float) ((Math.hypot(addButtonBackground.getX(), addButtonBackground.getY())
                + addButtonBackground.getWidth()) / addButtonBackground.getWidth() * 2);

        Animation animation = new Animation() {

            private boolean needsFragment = true;
            private float pivot;

            @Override
            public void initialize(int width, int height, int parentWidth, int parentHeight) {
                super.initialize(width, height, parentWidth, parentHeight);

                pivot = resolveSize(RELATIVE_TO_SELF, 0.5f, width, parentWidth);
            }

            @Override
            protected void applyTransformation(float interpolatedTime, Transformation t) {

                if (needsFragment && interpolatedTime >= 1) {
                    needsFragment = false;
                    showSourceAddFragment();
                } else {
                    float scaleFactor = 1.0f + ((scale - 1.0f) * interpolatedTime);
                    t.getMatrix().setScale(scaleFactor, scaleFactor, pivot, pivot);
                }
            }

            @Override
            public boolean willChangeBounds() {
                return true;
            }

        };

        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                circleDrawable.setColor(getResources().getColor(R.color.ACCENT_OPAQUE));
                addButtonBackground.setImageDrawable(circleDrawable);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if (needsButtonReset) {
                            addButton.setOnClickListener(SourceListFragment.this);
                            addButtonBackground.setScaleX(1.0f);
                            addButtonBackground.setScaleY(1.0f);
                            addButtonBackground.clearAnimation();
                            circleDrawable.setColor(getResources().getColor(R.color.ACCENT_OPAQUE));
                            addButtonBackground.setImageDrawable(circleDrawable);
                            addButton.setVisibility(View.VISIBLE);
                        }
                    }
                }, 100);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }

        });

        ValueAnimator buttonColorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
                getResources().getColor(R.color.ACCENT_OPAQUE),
                getResources().getColor(AppSettings.getBackgroundColorResource()));
        buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                circleDrawable.setColor((Integer) animation.getAnimatedValue());
                addButtonBackground.setImageDrawable(circleDrawable);
            }

        });

        DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator();

        animation.setDuration(ADD_ANIMATION_TIME);
        buttonColorAnimation.setDuration((long) (ADD_ANIMATION_TIME * 0.9));
        buttonColorAnimation.setInterpolator(decelerateInterpolator);
        animation.setInterpolator(decelerateInterpolator);

        // Post a delayed Runnable to ensure reset even if animation is interrupted
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (needsButtonReset) {
                    addButtonBackground.setScaleX(1.0f);
                    addButtonBackground.setScaleY(1.0f);
                    addButtonBackground.clearAnimation();
                    circleDrawable.setColor(getResources().getColor(R.color.ACCENT_OPAQUE));
                    addButtonBackground.setImageDrawable(circleDrawable);
                    addButton.setVisibility(View.VISIBLE);
                    needsButtonReset = false;
                }
            }
        }, (long) (ADD_ANIMATION_TIME * 1.1f));

        needsButtonReset = true;
        addButton.setVisibility(View.GONE);
        buttonColorAnimation.start();
        addButtonBackground.startAnimation(animation);
        break;
    default:
    }
}