List of usage examples for android.animation ArgbEvaluator ArgbEvaluator
ArgbEvaluator
From source file:com.phonemetra.deskclock.DeskClock.java
private void setBackgroundColor() { final int duration; if (mLastHourColor == UNKNOWN_COLOR_ID) { mLastHourColor = getResources().getColor(R.color.default_background); duration = BACKGROUND_COLOR_INITIAL_ANIMATION_DURATION_MILLIS; } else {/*from www . j ava2s .c o m*/ duration = getResources().getInteger(android.R.integer.config_longAnimTime); } final int currHourColor = Utils.getCurrentHourColor(this); if (mLastHourColor != currHourColor) { final ObjectAnimator animator = ObjectAnimator.ofInt(getWindow().getDecorView(), "backgroundColor", mLastHourColor, currHourColor); animator.setDuration(duration); animator.setEvaluator(new ArgbEvaluator()); animator.start(); mLastHourColor = currHourColor; } }
From source file:io.digibyte.tools.animation.BRAnimator.java
public static void animateBackgroundDim(final ViewGroup backgroundLayout, boolean reverse) { int transColor = reverse ? R.color.black_trans : android.R.color.transparent; int blackTransColor = reverse ? android.R.color.transparent : R.color.black_trans; ValueAnimator anim = new ValueAnimator(); anim.setIntValues(transColor, blackTransColor); anim.setEvaluator(new ArgbEvaluator()); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/* w w w .ja v a2 s. co m*/ public void onAnimationUpdate(ValueAnimator valueAnimator) { backgroundLayout.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); } }); anim.setDuration(SLIDE_ANIMATION_DURATION); anim.start(); }
From source file:org.odk.collect.android.views.ODKView.java
public void highlightWidget(FormIndex formIndex) { QuestionWidget qw = getQuestionWidget(formIndex); if (qw != null) { // postDelayed is needed because otherwise scrolling may not work as expected in case when // answers are validated during form finalization. new Handler().postDelayed(() -> { findViewById(R.id.odk_view_container).scrollTo(0, qw.getTop()); ValueAnimator va = new ValueAnimator(); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { va.setIntValues(getResources().getColor(R.color.red_500), getDrawingCacheBackgroundColor()); } else { // Avoid fading to black on certain devices and Android versions that may not support transparency TypedValue typedValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.windowBackground, typedValue, true); if (typedValue.type >= TypedValue.TYPE_FIRST_COLOR_INT && typedValue.type <= TypedValue.TYPE_LAST_COLOR_INT) { va.setIntValues(getResources().getColor(R.color.red_500), typedValue.data); } else { va.setIntValues(getResources().getColor(R.color.red_500), getDrawingCacheBackgroundColor()); }//w w w . ja va 2s . c o m } va.setEvaluator(new ArgbEvaluator()); va.addUpdateListener( valueAnimator -> qw.setBackgroundColor((int) valueAnimator.getAnimatedValue())); va.setDuration(2500); va.start(); }, 100); } }
From source file:com.mikhaellopez.saveinsta.activity.MainActivity.java
private void setThemeColor(int colorFrom, final int colorTo) { // Set Toolbar and NavigationBar color ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w w w . j a va 2 s . c o m public void onAnimationUpdate(ValueAnimator animator) { mToolbar.setBackgroundColor((int) animator.getAnimatedValue()); } }); colorAnimation.start(); // Set Status Bar color ValueAnimator colorAnimationDark = ValueAnimator.ofObject(new ArgbEvaluator(), darkerColor(colorFrom), darkerColor(colorTo)); colorAnimationDark.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor((int) animator.getAnimatedValue()); getWindow().setNavigationBarColor((int) animator.getAnimatedValue()); } } }); colorAnimationDark.start(); // Set Text and icon color int textColorFrom = getTextColorByBackground(colorFrom); int textColorTo = getTextColorByBackground(colorTo); if (textColorFrom != colorTo) { ValueAnimator colorAnimationText = ValueAnimator.ofObject(new ArgbEvaluator(), textColorFrom, textColorTo); colorAnimationText.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { mToolbarTitle.setTextColor((int) animator.getAnimatedValue()); if (mMenuItem != null) { mMenuItem.setIcon(isColorDark(colorTo) ? ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_info) : ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_info_dark)); } } }); colorAnimationText.start(); } mCurrentDominantColor = colorTo; }
From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java
private ValueAnimator getValueAnimator(int colorTo, int colorFrom) { final ValueAnimator colorAnimation; if (Build.VERSION.SDK_INT >= 19) colorAnimation = ObjectAnimator.ofObject(this, "setBackgroundColor", new ArgbEvaluator(), colorFrom, colorTo);/*from www . ja v a 2 s . c o m*/ else { colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); } return colorAnimation; }
From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java
private void fadeIn() { int colorFrom = Color.parseColor("#00000000"); int colorTo = Color.parseColor("#40000000"); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.setDuration(250); // milliseconds colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w w w. ja v a2s .com public void onAnimationUpdate(ValueAnimator animator) { setBackgroundColor((int) animator.getAnimatedValue()); } }); colorAnimation.start(); }
From source file:android.improving.utils.views.PagerSlidingTabStrip.java
/** * text animation//from w ww . j a va 2 s . com * @param view * @param color1 * @param color2 */ private void animTextColor(TextView view, int color1, int color2) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { view.setTextColor(color2); } else { if (color1 == color2) { view.setTextColor(color2); } else { ObjectAnimator backgroundColorAnimator = ObjectAnimator.ofObject(view, CHANGECOLORSTRING, new ArgbEvaluator(), color1, color2); backgroundColorAnimator.setDuration(100); backgroundColorAnimator.start(); } } }
From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java
public void fadeOut() { int colorFrom = Color.parseColor("#40000000"); int colorTo = Color.parseColor("#00000000"); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.setDuration(250); // milliseconds colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/* w w w . j a va 2 s.c om*/ public void onAnimationUpdate(ValueAnimator animator) { setBackgroundColor((int) animator.getAnimatedValue()); } }); colorAnimation.start(); }
From source file:android.support.graphics.drawable.AnimatedVectorDrawableCompat.java
/** * Utility function to fix color interpolation prior to Lollipop. Without this fix, colors * are evaluated as raw integers instead of as colors, which leads to artifacts during * fillColor animations./*from w w w.j av a2 s . com*/ */ private void setupColorAnimator(Animator animator) { if (animator instanceof AnimatorSet) { List<Animator> childAnimators = ((AnimatorSet) animator).getChildAnimations(); if (childAnimators != null) { for (int i = 0; i < childAnimators.size(); ++i) { setupColorAnimator(childAnimators.get(i)); } } } if (animator instanceof ObjectAnimator) { ObjectAnimator objectAnim = (ObjectAnimator) animator; final String propertyName = objectAnim.getPropertyName(); if ("fillColor".equals(propertyName) || "strokeColor".equals(propertyName)) { if (mArgbEvaluator == null) { mArgbEvaluator = new ArgbEvaluator(); } objectAnim.setEvaluator(mArgbEvaluator); } } }
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/*from ww w .ja v 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(); } }