List of usage examples for android.animation ValueAnimator getAnimatedValue
public Object getAnimatedValue()
ValueAnimator
when there is just one property being animated. From source file:org.sufficientlysecure.keychain.ui.BackupCodeFragment.java
private static void animateFlashText(final TextView[] textViews, int color1, int color2, boolean staySecondColor) { ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), color1, color2); anim.addUpdateListener(new AnimatorUpdateListener() { @Override// www.j av a2s.c om public void onAnimationUpdate(ValueAnimator animator) { for (TextView textView : textViews) { textView.setTextColor((Integer) animator.getAnimatedValue()); } } }); anim.setRepeatMode(ValueAnimator.REVERSE); anim.setRepeatCount(staySecondColor ? 4 : 5); anim.setDuration(180); anim.setInterpolator(new AccelerateInterpolator()); anim.start(); }
From source file:com.musenkishi.atelier.Atelier.java
private static void applyColorToView(final ImageView imageView, int color, boolean fromCache, boolean shouldMask) { if (fromCache) { if (shouldMask) { if (imageView.getDrawable() != null) { imageView.getDrawable().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY); } else if (imageView.getBackground() != null) { imageView.getBackground().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY); }//from w w w.j av a 2 s. com } else { imageView.setBackgroundColor(color); } } else { if (shouldMask) { Integer colorFrom; ValueAnimator.AnimatorUpdateListener imageAnimatorUpdateListener = new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { if (imageView.getDrawable() != null) { imageView.getDrawable().mutate().setColorFilter( (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY); } else if (imageView.getBackground() != null) { imageView.getBackground().mutate().setColorFilter( (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY); } } }; ValueAnimator.AnimatorUpdateListener animatorUpdateListener; PaletteTag paletteTag = (PaletteTag) imageView.getTag(viewTagKey); animatorUpdateListener = imageAnimatorUpdateListener; colorFrom = paletteTag.getColor(); imageView.setTag(viewTagKey, new PaletteTag(paletteTag.getId(), color)); Integer colorTo = color; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(animatorUpdateListener); colorAnimation.setDuration(300); colorAnimation.start(); } else { Drawable preDrawable; if (imageView.getBackground() == null) { preDrawable = new ColorDrawable(Color.TRANSPARENT); } else { preDrawable = imageView.getBackground(); } TransitionDrawable transitionDrawable = new TransitionDrawable( new Drawable[] { preDrawable, new ColorDrawable(color) }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { imageView.setBackground(transitionDrawable); } else { imageView.setBackgroundDrawable(transitionDrawable); } transitionDrawable.startTransition(300); } } }
From source file:com.musenkishi.atelier.Atelier.java
private static void applyColorToView(final FloatingActionButton floatingActionButton, int color, boolean fromCache, boolean shouldMask) { if (fromCache) { if (shouldMask) { if (floatingActionButton.getDrawable() != null) { floatingActionButton.getDrawable().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY); } else if (floatingActionButton.getBackground() != null) { floatingActionButton.getBackground().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY); }/*from www . j a v a 2s. c o m*/ } else { ColorStateList colorStateList = ColorStateList.valueOf(color); floatingActionButton.setBackgroundTintList(colorStateList); } } else { if (shouldMask) { Integer colorFrom; ValueAnimator.AnimatorUpdateListener imageAnimatorUpdateListener = new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { if (floatingActionButton.getDrawable() != null) { floatingActionButton.getDrawable().mutate().setColorFilter( (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY); } else if (floatingActionButton.getBackground() != null) { floatingActionButton.getBackground().mutate().setColorFilter( (Integer) valueAnimator.getAnimatedValue(), PorterDuff.Mode.MULTIPLY); } } }; ValueAnimator.AnimatorUpdateListener animatorUpdateListener; PaletteTag paletteTag = (PaletteTag) floatingActionButton.getTag(viewTagKey); animatorUpdateListener = imageAnimatorUpdateListener; colorFrom = paletteTag.getColor(); floatingActionButton.setTag(viewTagKey, new PaletteTag(paletteTag.getId(), color)); Integer colorTo = color; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(animatorUpdateListener); colorAnimation.setDuration(300); colorAnimation.start(); } else { Integer colorFrom = Color.parseColor("#FFFAFAFA"); ColorStateList colorStateList = floatingActionButton.getBackgroundTintList(); if (colorStateList != null) { colorFrom = colorStateList.getDefaultColor(); } Integer colorTo = color; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { int color = (Integer) animator.getAnimatedValue(); floatingActionButton.setBackgroundTintList(ColorStateList.valueOf(color)); } }); colorAnimation.setDuration(300); colorAnimation.start(); } } }
From source file:com.android.argb.edhlc.Utils.java
public static void collapse(Context context, final CardView card, TextView title, ImageView selector, int minHeight, int maxHeight) { title.setTextColor(ContextCompat.getColor(context, R.color.secondary_text)); Animation rotation = AnimationUtils.loadAnimation(context, R.anim.rotate_180_clockwise); selector.startAnimation(rotation);/* w w w .j a v a2 s . com*/ selector.setColorFilter(ContextCompat.getColor(context, R.color.secondary_text)); ValueAnimator anim = ValueAnimator.ofInt(maxHeight, minHeight); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = card.getLayoutParams(); layoutParams.height = val; card.setLayoutParams(layoutParams); } }); anim.start(); }
From source file:com.android.argb.edhlc.Utils.java
public static void expand(Context context, final CardView card, TextView title, ImageView selector, int minHeight, int maxHeight) { title.setTextColor(ContextCompat.getColor(context, R.color.accent_color_dark)); Animation rotation = AnimationUtils.loadAnimation(context, R.anim.rotate_180_anticlockwise); selector.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.arrow_up)); selector.setRotation(0);//from w w w. j av a 2s. com selector.startAnimation(rotation); selector.setColorFilter(ContextCompat.getColor(context, R.color.accent_color_dark)); ValueAnimator anim = ValueAnimator.ofInt(minHeight, maxHeight); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = card.getLayoutParams(); layoutParams.height = val; card.setLayoutParams(layoutParams); Utils.makeViewVisible(card); } }); anim.start(); }
From source file:com.azita.iot.ioclient.activity.MainActivity.java
private static void setProgressAnimatedJdk(final SeekBar seekBar, int from, int to) { ValueAnimator anim = ValueAnimator.ofInt(from, to); anim.setDuration(100);/*from w w w.j a v a 2 s . c o m*/ anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int animProgress = (Integer) animation.getAnimatedValue(); seekBar.setProgress(animProgress); } }); anim.start(); }
From source file:org.hawkular.client.android.util.ViewTransformer.java
@Override public void onAnimationUpdate(ValueAnimator animator) { view.getLayoutParams().height = (int) animator.getAnimatedValue(); view.requestLayout();/*from ww w.j av a2 s .co m*/ }
From source file:com.redbooth.demo.MainActivity.java
private void initializeBackgroundTransitions() { final Resources resources = getResources(); final int colorPage1 = ResourcesCompat.getColor(resources, R.color.page1, getTheme()); final int colorPage2 = ResourcesCompat.getColor(resources, R.color.page2, getTheme()); final int colorPage3 = ResourcesCompat.getColor(resources, R.color.page3, getTheme()); final int colorPage4 = ResourcesCompat.getColor(resources, R.color.page4, getTheme()); backgroundAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), colorPage1, colorPage2, colorPage3, colorPage4);/*from w ww .ja va 2 s .co m*/ backgroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { coordinatorLayout.setBackgroundColor((int) animation.getAnimatedValue()); } }); }
From source file:xyz.klinker.android.article.ArticleScrollListener.java
private void animateBackgroundColor(int from, int to, Interpolator interpolator) { final ValueAnimator anim = new ValueAnimator(); anim.setIntValues(from, to);//from w ww. jav a2 s . com anim.setEvaluator(new ArgbEvaluator()); anim.setInterpolator(interpolator); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { toolbar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); statusBar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); } }); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); isUpdatingBackground = false; } }); anim.setDuration(ANIMATION_DURATION); anim.start(); isUpdatingBackground = true; }
From source file:com.oprisnik.navdrawer.NavDrawerActivity.java
public void animateStatusBarBackgroundColor(int fromColor, int toColor) { if (mStatusBarColorAnimator != null) { mStatusBarColorAnimator.cancel(); mStatusBarColorAnimator = null;/* w w w . ja va2 s . c o m*/ } if (mDrawerLayout != null) { mStatusBarColorAnimator = ObjectAnimator.ofInt(mDrawerLayout, "statusBarBackgroundColor", fromColor, toColor); mStatusBarColorAnimator.setDuration(200); mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR); mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { ViewCompat.postInvalidateOnAnimation(mDrawerLayout); } }); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mStatusBarColorAnimator = ValueAnimator.ofArgb(fromColor, toColor); mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void onAnimationUpdate(ValueAnimator animation) { final int val = (Integer) animation.getAnimatedValue(); getWindow().setStatusBarColor(val); } }); } } if (mStatusBarColorAnimator != null) { mStatusBarColorAnimator.start(); } }