List of usage examples for android.animation ValueAnimator setDuration
@Override public ValueAnimator setDuration(long duration)
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 {//from w ww .j a v a 2 s . 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: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); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from www .j ava2s . c o m*/ public void onAnimationUpdate(ValueAnimator animation) { int animProgress = (Integer) animation.getAnimatedValue(); seekBar.setProgress(animProgress); } }); anim.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/*from w w w . j av a 2 s . 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
private static ValueAnimator loadAnimator(Context context, int resId) { ValueAnimator animator = (ValueAnimator) AnimatorInflater.loadAnimator(context, resId); animator.setDuration(animator.getDuration() * ANIMATION_MULTIPLIER); return animator; }
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();/*w w w . jav a 2s . c om*/ }
From source file:org.hawkular.client.android.util.ViewTransformer.java
@UiThread public void collapse() { ValueAnimator animator = ValueAnimator.ofInt(Views.measureHeight(view), 0); animator.setInterpolator(new LinearOutSlowInInterpolator()); animator.setDuration(Durations.MEDIUM); animator.addUpdateListener(this); animator.addListener(new AnimatorListenerAdapter() { @Override/* w w w . j a v a 2s . co m*/ public void onAnimationEnd(Animator animation) { view.setVisibility(View.GONE); } }); animator.start(); }
From source file:ru.tinkoff.acquiring.sdk.views.KeyView.java
private ValueAnimator createCircleAnimator() { final float maxDimen = Math.max(getWidth(), getHeight()) * 0.8F; final ValueAnimator animator = ValueAnimator.ofFloat(0F, maxDimen); animator.setDuration(CIRCLE_ANIMATION_DURATION_MILLIS); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w ww . java 2 s .c o m*/ public void onAnimationUpdate(ValueAnimator animation) { circleRadius = (Float) animation.getAnimatedValue(); invalidate(); } }); animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { drawingPressAnimation = false; invalidate(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); return animator; }
From source file:com.waz.zclient.pages.main.conversation.views.row.message.views.TextMessageWithTimestamp.java
public ValueAnimator createHeightAnimator(final View view, final int start, final int end) { ValueAnimator animator = ValueAnimator.ofInt(start, end); animator.setDuration(animationDuration); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from ww w .j a va 2 s .com*/ public void onAnimationUpdate(final ValueAnimator valueAnimator) { ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); layoutParams.height = (Integer) valueAnimator.getAnimatedValue(); view.setLayoutParams(layoutParams); } }); return animator; }
From source file:com.dmallcott.progressfloatingactionbutton.ProgressView.java
public void setCurrentProgress(int currentProgress, boolean animate) { // If the view is animating no further actions are allowed if (isAnimating) return;/*from w w w . ja v a 2 s .c o m*/ if (this.mTargetProgress >= mTotalProgress) this.mTargetProgress = mTotalProgress; else this.mTargetProgress = currentProgress; if (animate && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // Animations are only available from API 11 and forth ValueAnimator va = ValueAnimator.ofInt(mCurrentProgress, mTargetProgress); va.setInterpolator(new AccelerateDecelerateInterpolator()); va.setDuration(mAnimationDuration); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onAnimationUpdate(ValueAnimator animation) { mCurrentProgress = (Integer) animation.getAnimatedValue(); ProgressView.this.invalidate(); } }); va.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { isAnimating = true; } @Override public void onAnimationEnd(Animator animation) { isAnimating = false; } @Override public void onAnimationCancel(Animator animation) { isAnimating = false; } @Override public void onAnimationRepeat(Animator animation) { isAnimating = true; } }); va.start(); } else { mCurrentProgress = mTargetProgress; invalidate(); } if (this.mTargetProgress == mTotalProgress) mListener.onProgressCompleted(); }
From source file:com.wytiger.common.widget.SlideSwitch.java
private void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left); toDestAnim.setDuration(500); toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); toDestAnim.start();/*from w w w. j av a2s . co m*/ toDestAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { frontRect_left = (Integer) animation.getAnimatedValue(); alpha = (int) (255 * (float) frontRect_left / (float) max_left); invalidateView(); } }); toDestAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (toRight) { isOpen = true; if (listener != null) listener.open(); frontRect_left_begin = max_left; } else { isOpen = false; if (listener != null) listener.close(); frontRect_left_begin = min_left; } } }); }