List of usage examples for android.animation ValueAnimator setInterpolator
@Override public void setInterpolator(TimeInterpolator value)
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 ww .jav a 2 s. c om 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.jungle.toolbaractivity.layout.HorizontalSwipeBackLayout.java
private void continueAnimation(float horzOffset, int width) { ValueAnimator animator = ValueAnimator.ofFloat(horzOffset, width); animator.setInterpolator(new AccelerateInterpolator()); animator.setDuration((long) (150 * Math.abs(width - horzOffset) / width)); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override// w w w . j a v a2 s .co m public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); updateSlideOffset(value); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (mSlideListener != null) { mSlideListener.onSlideFinished(); } } }); animator.start(); }
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);//from w w w. j a va 2 s . c o m toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); toDestAnim.start(); 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; } } }); }
From source file:io.github.sin3hz.wifispinnerview.WifiSpinnerDrawable.java
private void setupAnimators() { AnimatorSet set = new AnimatorSet(); for (int i = 0; i < mSpinnerCount; i++) { final int index = i; final ValueAnimator sweepAnimator = ValueAnimator.ofFloat(0, MAX_SWEEP_ANGLE); sweepAnimator.setInterpolator(SWEEP_ANIMATOR_INTERPOLATOR); sweepAnimator.setDuration(mSweepAnimatorDuration); sweepAnimator.setRepeatMode(ValueAnimator.RESTART); sweepAnimator.setRepeatCount(ValueAnimator.INFINITE); sweepAnimator.setStartDelay(index * SWEEP_ANIMATOR_DELAY); sweepAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w w w. j a va 2 s . c om public void onAnimationUpdate(ValueAnimator animation) { mSpinners[index].sweepAngle = (float) animation.getAnimatedValue(); mSpinners[index].updatePath(); invalidateSelf(); } }); sweepAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationRepeat(Animator animation) { mSpinners[index].sweepAngleOffset = (mSpinners[index].sweepAngleOffset + MAX_SWEEP_ANGLE) % 360; mSpinners[index].updatePath(); } }); set.playTogether(sweepAnimator); } mSweepAnimator = set; mAngleAnimator = ValueAnimator.ofFloat(0, 360); mAngleAnimator.setInterpolator(ANGLE_ANIMATOR_INTERPOLATOR); mAngleAnimator.setRepeatCount(ValueAnimator.INFINITE); mAngleAnimator.setRepeatMode(ValueAnimator.RESTART); mAngleAnimator.setDuration(ANGLE_ANIMATOR_DURATION); mAngleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mGlobalAngle = (float) animation.getAnimatedValue(); updatePath(); invalidateSelf(); } }); }
From source file:com.example.administrator.iclub21.view.SlideSwitch.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left); toDestAnim.setDuration(500);/*from w w w .j ava2 s . c o m*/ toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); toDestAnim.start(); 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; } } }); }
From source file:org.catrobat.paintroid.ui.BottomBar.java
private void delayedAnimateSelectedTool(int startDelay) { ImageButton button = getToolButtonByToolType(mCurrentToolType); int color = ContextCompat.getColor(button.getContext(), R.color.bottom_bar_button_activated); int fadedColor = color & 0x00ffffff; ValueAnimator valueAnimator = ObjectAnimator.ofInt(button, "backgroundColor", color, fadedColor); valueAnimator.setEvaluator(new ArgbEvaluator()); valueAnimator.setInterpolator(new LinearInterpolator()); valueAnimator.setDuration(500);//w w w.ja v a 2s. c o m valueAnimator.setRepeatCount(5); valueAnimator.setRepeatMode(ValueAnimator.REVERSE); valueAnimator.setStartDelay(startDelay); valueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (PaintroidApplication.currentTool != null) { setActivatedToolButton(PaintroidApplication.currentTool.getToolType()); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); valueAnimator.start(); }
From source file:com.fruit.widget.SlideSwitch.java
public void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left); toDestAnim.setDuration(duration);//from w w w. j av a 2 s . co m toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); toDestAnim.start(); 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; } } }); }
From source file:com.dean.phonesafe.ui.SlideSwitch.java
public void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left); toDestAnim.setDuration(500);//from ww w. ja v a 2 s . c o m toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); toDestAnim.start(); 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; } } }); }
From source file:com.audionote.widget.SlideSwitch.java
public void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left); toDestAnim.setDuration(200);/*from w w w . ja v a 2 s .co m*/ toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); toDestAnim.start(); 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; } } }); }
From source file:im.ene.ribbon.TabletActionTabView.java
@Override protected void onStatusChanged(final boolean expanded, final int size, final boolean animate) { if (!animate) { updateLayoutOnAnimation(1, expanded); return;/*www . j av a 2 s .c om*/ } final ValueAnimator animator = ObjectAnimator.ofFloat(0, 1); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator animation) { updateLayoutOnAnimation(animation.getAnimatedFraction(), expanded); } }); animator.setDuration(animationDuration); animator.setInterpolator(interpolator); animator.start(); }