List of usage examples for android.animation ValueAnimator setInterpolator
@Override public void setInterpolator(TimeInterpolator value)
From source file:com.dycody.android.idealnote.NavigationDrawerFragment.java
void animateBurger(int targetShape) { if (mDrawerToggle != null) { if (targetShape != BURGER && targetShape != ARROW) return; ValueAnimator anim = ValueAnimator.ofFloat((targetShape + 1) % 2, targetShape); anim.addUpdateListener(valueAnimator -> { float slideOffset = (Float) valueAnimator.getAnimatedValue(); mDrawerToggle.onDrawerSlide(mDrawerLayout, slideOffset); });// ww w . ja va 2 s .c om anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(500); anim.start(); } }
From source file:com.commonsware.cwac.crossport.design.widget.FloatingActionButtonImpl.java
private ValueAnimator createAnimator(@NonNull ShadowAnimatorImpl impl) { final ValueAnimator animator = new ValueAnimator(); animator.setInterpolator(ANIM_INTERPOLATOR); animator.setDuration(PRESSED_ANIM_DURATION); animator.addListener(impl);/*w ww . j av a2 s . c om*/ animator.addUpdateListener(impl); animator.setFloatValues(0, 1); return animator; }
From source file:com.arsy.maps_library.MapRipple.java
private void startAnimation(final int numberOfRipple) { ValueAnimator animator = ValueAnimator.ofInt(0, (int) mDistance); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setRepeatMode(ValueAnimator.RESTART); animator.setDuration(mRippleDuration); animator.setEvaluator(new IntEvaluator()); animator.setInterpolator(new LinearInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override// w w w. ja v a2 s . c o m public void onAnimationUpdate(ValueAnimator valueAnimator) { int animated = (int) valueAnimator.getAnimatedValue(); mGroundOverlays[numberOfRipple].setDimensions(animated); if (mDistance - animated <= 10) { if (mLatLng != mPrevLatLng) { mGroundOverlays[numberOfRipple].setPosition(mLatLng); } } } }); animator.start(); mAnimators[numberOfRipple] = animator; }
From source file:cn.com.hgh.view.SlideSwitch.java
public void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left); toDestAnim.setDuration(500);// ww w .java 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.example.waitou.rxjava.LoadingView.java
private void buildAnimator() { final ValueAnimator valueAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(ANIMATOR_DURATION); valueAnimator.setRepeatCount(-1);/* w ww .jav a 2s . co m*/ valueAnimator.setInterpolator(new LinearInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mRotation = (float) valueAnimator.getAnimatedValue(); invalidate(); } }); animator = valueAnimator; animatorSet = buildFlexibleAnimation(); animatorSet.addListener(animatorListener); }
From source file:com.awt.supark.LayoutHandler.java
public void pullDown(final MainActivity act) { act.animInProgress = true;//w w w . jav a2s .co m act.CarHandler.updateLicense(act); // ****** BUTTON AND LAYOUT PULL DOWN ANIMATION // Declaring animator ValueAnimator animation = ValueAnimator.ofFloat(0f, 1f); // Sets the animation properties animation.setDuration(act.layoutPullUpDuration); animation.setInterpolator(new AccelerateDecelerateInterpolator()); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); act.tableRowTopHalf.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, value)); act.btnMap.setAlpha(value); act.btnCars.setAlpha(value); act.btnStatistics.setAlpha(value); act.btnEtc.setAlpha(value); } }); animation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { // Starts layout pull down and fade out animation act.otherContent.startAnimation(act.anim_slide_down_fade_out); act.anim_slide_down_fade_out.setFillAfter(true); // Makes layout invisible act.otherContent.setVisibility(View.GONE); } @Override public void onAnimationEnd(Animator animation) { act.contentLinear.setVisibility(View.VISIBLE); // ****** UI ELEMENTS FADE IN ANIMATION ****** // Declaring animator ValueAnimator nextAnimation = ValueAnimator.ofFloat(0.17f, 1f); // Sets the animation properties nextAnimation.setDuration(act.layoutFadeInDuration); nextAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); act.contentLinear.setAlpha(value); } }); nextAnimation.start(); act.pullUp = false; act.openedLayout = 0; act.animInProgress = false; FragmentTransaction transaction = act.fragmentManager.beginTransaction(); transaction.remove(act.fragmentManager.findFragmentById(R.id.otherContent)); transaction.commit(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animation.start(); }
From source file:com.alimuzaffar.lib.pin.PinEntryEditText.java
private void animatePopIn() { ValueAnimator va = ValueAnimator.ofFloat(1, getPaint().getTextSize()); va.setDuration(200);//from w ww. j ava 2 s . c o m va.setInterpolator(new OvershootInterpolator()); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mLastCharPaint.setTextSize((Float) animation.getAnimatedValue()); PinEntryEditText.this.invalidate(); } }); if (getText().length() == mMaxLength && mOnPinEnteredListener != null) { va.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mOnPinEnteredListener.onPinEntered(getText()); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); } va.start(); }
From source file:com.example.waitou.rxjava.LoadingView.java
/** * build FlexibleAnimation to control the progress * * @return Animatorset for control the progress *///from w w w . j a v a 2 s . co m private AnimatorSet buildFlexibleAnimation() { final Ring ring = mRing; AnimatorSet set = new AnimatorSet(); ValueAnimator increment = ValueAnimator.ofFloat(0, MAX_PROGRESS_ARC - MIN_PROGRESS_ARC) .setDuration(ANIMATOR_DURATION / 2); increment.setInterpolator(new LinearInterpolator()); increment.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float sweeping = ring.sweeping; final float value = (float) animation.getAnimatedValue(); ring.sweep = sweeping + value; invalidate(); } }); increment.addListener(animatorListener); ValueAnimator reduce = ValueAnimator.ofFloat(0, MAX_PROGRESS_ARC - MIN_PROGRESS_ARC) .setDuration(ANIMATOR_DURATION / 2); reduce.setInterpolator(interpolator); reduce.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float sweeping = ring.sweeping; float starting = ring.starting; float value = (float) animation.getAnimatedValue(); ring.sweep = sweeping - value; ring.start = starting + value; } }); set.play(reduce).after(increment); return set; }
From source file:ch.gianulli.flashcards.ui.Flashcard.java
private void expandButtonBar() { mButtonBarShowing = true;//w w w . j a v a2 s . c o m mButtonBar.setVisibility(View.VISIBLE); mButtonBar.setAlpha(0.0f); final int startingHeight = mCardView.getHeight(); final ViewTreeObserver observer = mCardView.getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { // We don't want to continue getting called for every listview drawing. if (observer.isAlive()) { observer.removeOnPreDrawListener(this); } final int endingHeight = mCardView.getHeight(); final int distance = endingHeight - startingHeight; mCardView.getLayoutParams().height = startingHeight; mCardView.requestLayout(); ValueAnimator heightAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(300); heightAnimator.setInterpolator(new DecelerateInterpolator()); heightAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { Float value = (Float) animator.getAnimatedValue(); mCardView.getLayoutParams().height = (int) (value * distance + startingHeight); mCardView.requestLayout(); } }); heightAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCardView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; } }); mButtonBar.setLayerType(View.LAYER_TYPE_HARDWARE, null); ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mButtonBar, "alpha", 0.0f, 1.0f); alphaAnimator.setInterpolator(new DecelerateInterpolator()); alphaAnimator.setDuration(300); alphaAnimator.setStartDelay(100); AnimatorSet set = new AnimatorSet(); set.playTogether(heightAnimator, alphaAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mButtonBar.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } }); set.start(); return false; } }); }
From source file:com.test.slidebutton.SlideButton.java
/** * max_leftmin_left(moveToboolean toRight) * @param toRight//w w w . ja v a2 s. c o m */ @Deprecated private void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(sliderCurrentLeft, toRight ? max_left : min_left); toDestAnim.setDuration(200); toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); // toDestAnim.setInterpolator(new OvershootInterpolator()); toDestAnim.start(); toDestAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { sliderCurrentLeft = (Integer) animation.getAnimatedValue(); alpha = (int) (255 * (float) sliderCurrentLeft / (float) max_left); if (alpha < 0) alpha = 0; if (alpha > 255) alpha = 255; caculateColor(); invalidateView(); } }); toDestAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (toRight) { isOpen = true; if (listener != null) { listener.open(); } sliderCurrentLeft = sliderMoveStartLeft = max_left; alpha = 255; } else { isOpen = false; if (listener != null) { listener.close(); } sliderCurrentLeft = sliderMoveStartLeft = min_left; alpha = 0; } invalidateView(); } }); }