List of usage examples for android.animation ValueAnimator start
@Override public void start()
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 w ww . jav a2 s . 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: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.j av a 2s. c o m*/ public void onAnimationUpdate(ValueAnimator valueAnimator) { backgroundLayout.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); } }); anim.setDuration(SLIDE_ANIMATION_DURATION); anim.start(); }
From source file:com.musenkishi.atelier.Atelier.java
private static void applyColorToView(final TextView textView, int color, boolean fromCache) { if (fromCache) { textView.setTextColor(color);/*from w ww .j a v a 2 s . c om*/ } else { Integer colorFrom = textView.getCurrentTextColor(); Integer colorTo = color; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { textView.setTextColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.start(); } }
From source file:com.musenkishi.atelier.Atelier.java
private static void applyColorToView(final CardView cardView, int color, boolean fromCache) { if (fromCache) { cardView.setCardBackgroundColor(color); } else {/*w w w . ja v a 2s . c o m*/ Integer colorFrom = Color.parseColor("#FFFAFAFA"); //Default light CardView color. Integer colorTo = color; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { cardView.setCardBackgroundColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.setDuration(300); colorAnimation.start(); } }
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/* w w w .j a va 2s. 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:android.support.v17.leanback.app.PlaybackSupportFragment.java
/** * if first animator is still running, reverse it; otherwise start second animator. *///from w w w .j av a2s . c o m static void reverseFirstOrStartSecond(ValueAnimator first, ValueAnimator second, boolean runAnimation) { if (first.isStarted()) { first.reverse(); if (!runAnimation) { first.end(); } } else { second.start(); if (!runAnimation) { second.end(); } } }
From source file:org.hawkular.client.android.util.ViewTransformer.java
@UiThread public void expand() { view.setVisibility(View.VISIBLE); ValueAnimator animator = ValueAnimator.ofInt(0, Views.measureHeight(view)); animator.setInterpolator(new LinearOutSlowInInterpolator()); animator.setDuration(Durations.MEDIUM); animator.addUpdateListener(this); animator.start(); }
From source file:com.waz.zclient.pages.main.conversation.views.row.message.views.TextMessageWithTimestamp.java
private void expandTimestamp() { if (messageViewContainer.getShownTimestampView() != null && messageViewContainer.getShownTimestampView() != this) { messageViewContainer.getShownTimestampView().collapseTimestamp(); }//from w w w . j a v a 2 s . c o m messageViewContainer.getTimestampShownSet().add(messageId); messageViewContainer.setShownTimestampView(this); timestampTextView.setVisibility(VISIBLE); View parent = (View) timestampTextView.getParent(); final int widthSpec = MeasureSpec.makeMeasureSpec( parent.getMeasuredWidth() - parent.getPaddingLeft() - parent.getPaddingRight(), MeasureSpec.AT_MOST); final int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); timestampTextView.measure(widthSpec, heightSpec); ValueAnimator animator = createHeightAnimator(timestampTextView, 0, timestampTextView.getMeasuredHeight()); animator.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 www . j a v a 2 s. c om anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int animProgress = (Integer) animation.getAnimatedValue(); seekBar.setProgress(animProgress); } }); anim.start(); }
From source file:com.insalyon.les24heures.view.DrawerArrowDrawable.java
public void animateToSandwich() { final DrawerArrowDrawable self = this; ValueAnimator animation = ValueAnimator.ofFloat(1f, 0f); animation.setDuration(500);// www. j ava 2s .co m animation.start(); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { self.setParameter((Float) animation.getAnimatedValue()); } }); this.setParameter(0); }