List of usage examples for android.animation ValueAnimator setDuration
@Override public ValueAnimator setDuration(long duration)
From source file:com.waz.zclient.pages.main.conversation.views.row.footer.FooterViewController.java
public ValueAnimator createHeightAnimator(final View view, final int start, final int end) { ValueAnimator animator = ValueAnimator.ofInt(start, end); animator.setDuration(250); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w w w .j a va 2 s. com*/ public void onAnimationUpdate(final ValueAnimator valueAnimator) { ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); if (layoutParams == null) { // needed for tests return; } layoutParams.height = (Integer) valueAnimator.getAnimatedValue(); view.setLayoutParams(layoutParams); } }); return animator; }
From source file:com.advaitaworld.widgets.SlidingTabLayout.java
private void updateTitleColors(int prevSelectedPosition, int newSelectedPosition) { if (mSelectedTabColor == 0 && mDefaultTabColor == 0) { return;/*from w w w . j ava 2s . c om*/ } View tabViewPrev = mTabStrip.getChildAt(prevSelectedPosition); View tabViewNew = mTabStrip.getChildAt(newSelectedPosition); final TextView tabTitlePrev = getTabTitleView(tabViewPrev); final TextView tabTitleNew = getTabTitleView(tabViewNew); ArgbEvaluator evaluator = new ArgbEvaluator(); ValueAnimator anim1 = new ValueAnimator(); anim1.setIntValues(mDefaultTabColor, mSelectedTabColor); anim1.setEvaluator(evaluator); anim1.setDuration(300); anim1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { tabTitleNew.setTextColor((Integer) valueAnimator.getAnimatedValue()); } }); ValueAnimator anim2 = new ValueAnimator(); anim2.setIntValues(mSelectedTabColor, mDefaultTabColor); anim2.setEvaluator(evaluator); anim2.setDuration(300); anim2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { tabTitlePrev.setTextColor((Integer) valueAnimator.getAnimatedValue()); } }); anim1.start(); anim2.start(); }
From source file:com.awt.supark.LayoutHandler.java
public void pullDown(final MainActivity act) { act.animInProgress = true;/* w w w .j a v a2 s . c om*/ 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.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); });// w ww.j av a2 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);//from ww w . jav a 2 s.c om animator.addUpdateListener(impl); animator.setFloatValues(0, 1); return animator; }
From source file:com.alimuzaffar.lib.pin.PinEntryEditText.java
private void animatePopIn() { ValueAnimator va = ValueAnimator.ofFloat(1, getPaint().getTextSize()); va.setDuration(200); va.setInterpolator(new OvershootInterpolator()); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w ww . j a v a2s. co m*/ 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.folioreader.view.ConfigView.java
private void toggleBlackTheme() { int day = getResources().getColor(R.color.white); int night = getResources().getColor(R.color.night); int darkNight = getResources().getColor(R.color.dark_night); final int diffNightDark = night - darkNight; ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), mIsNightMode ? night : day, mIsNightMode ? day : night); colorAnimation.setDuration(FADE_DAY_NIGHT_MODE); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w ww . j av a 2s. c om public void onAnimationUpdate(ValueAnimator animator) { int value = (int) animator.getAnimatedValue(); mContainer.setBackgroundColor(value); if (mConfigViewCallback != null) { mConfigViewCallback.onBackgroundUpdate(value - diffNightDark); } } }); colorAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { mIsNightMode = !mIsNightMode; Config.getConfig().setNightMode(mIsNightMode); mConfigViewCallback.onConfigChange(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); colorAnimation.setDuration(FADE_DAY_NIGHT_MODE); colorAnimation.start(); }
From source file:com.brayanarias.alarmproject.activity.AlarmScreenActivity.java
private void starAnimation() { View pulseView = findViewById(R.id.pulse); View pulseDismiss = findViewById(R.id.pulseDismiss); View pulseSnooze = findViewById(R.id.pulseSnooze); ValueAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(View.SCALE_X, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.ALPHA, 1.0f, 0.0f)); pulseAnimator.setDuration(2000); pulseAnimator.setRepeatCount(ValueAnimator.INFINITE); Interpolator interpolator = PathInterpolatorCompat.create(0.0f, 0.0f, 0.2f, 1.0f); pulseAnimator.setInterpolator(interpolator); pulseAnimator.start();/* w ww. jav a 2s .c o m*/ ValueAnimator dismissAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseDismiss, PropertyValuesHolder.ofFloat(View.SCALE_X, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.ALPHA, 1.0f, 0.0f)); dismissAnimator.setDuration(1000); dismissAnimator.setRepeatCount(ValueAnimator.INFINITE); dismissAnimator.setInterpolator(interpolator); dismissAnimator.start(); ValueAnimator snoozeAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseSnooze, PropertyValuesHolder.ofFloat(View.SCALE_X, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.ALPHA, 1.0f, 0.0f)); snoozeAnimator.setDuration(1000); snoozeAnimator.setRepeatCount(ValueAnimator.INFINITE); snoozeAnimator.setInterpolator(interpolator); snoozeAnimator.start(); }
From source file:com.test.slidebutton.SlideButton.java
/** * max_leftmin_left(moveToboolean toRight) * @param toRight/*w ww . j a v a2 s . com*/ */ @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(); } }); }
From source file:com.facebook.react.modules.statusbar.StatusBarModule.java
@ReactMethod public void setColor(final int color, final boolean animated, final Promise res) { final Activity activity = getCurrentActivity(); if (activity == null) { res.reject(ERROR_NO_ACTIVITY, ERROR_NO_ACTIVITY_MESSAGE); return;/* w ww .j a va 2 s. co m*/ } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { UiThreadUtil.runOnUiThread(new Runnable() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void run() { if (animated) { int curColor = activity.getWindow().getStatusBarColor(); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), curColor, color); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { activity.getWindow().setStatusBarColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.setDuration(300).setStartDelay(0); colorAnimation.start(); } else { activity.getWindow().setStatusBarColor(color); } res.resolve(null); } }); } else { res.resolve(null); } }