List of usage examples for android.animation ValueAnimator start
@Override public void start()
From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java
public void fadeInSignal(final int colorTo, final ValueAnimator.AnimatorUpdateListener updateListener) { final int colorFrom = DEFAULT_BACKGROUND_COLOR; final ValueAnimator colorAnimation = getValueAnimator(colorTo, colorFrom); colorAnimation.setDuration(DEFAULT_DURATION_ENTER); // milliseconds colorAnimation.addUpdateListener(updateListener); colorAnimation.addListener(new Animator.AnimatorListener() { @Override// w ww .j a va 2 s . c o m public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { final ValueAnimator colorAnimation = getValueAnimator(colorFrom, colorTo); colorAnimation.setDuration(DEFAULT_DURATION_EXIT); // milliseconds colorAnimation.addUpdateListener(updateListener); colorAnimation.start(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); colorAnimation.start(); }
From source file:com.musenkishi.wally.activities.ImageDetailsActivity.java
private void setupPaddings(final Size size, boolean animate) { int animationDuration = animate ? 300 : 0; photoView.setScaleType(ImageView.ScaleType.CENTER_CROP); photoViewAttacher.setScaleType(ImageView.ScaleType.CENTER_CROP); final int sidePadding = getResources() .getDimensionPixelSize(R.dimen.activity_details_scrollview_side_padding); int fabPadding = getResources().getDimensionPixelSize(R.dimen.fab_padding_positive); int minimumAllowedHeight = fabPadding; if (size.getHeight() < minimumAllowedHeight) { size.setHeight(size.getHeight()); ValueAnimator valueAnimator = ValueAnimator.ofInt(photoLayoutHolder.getPaddingTop()); valueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); valueAnimator.setDuration(animationDuration); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/* w w w . ja va 2 s . co m*/ public void onAnimationUpdate(ValueAnimator valueAnimator) { photoLayoutHolder.setPadding(0, (Integer) valueAnimator.getAnimatedValue(), 0, 0); } }); valueAnimator.start(); } else { photoLayoutHolder.setPadding(0, 0, 0, 0); } scrollView.setPadding(0, 0, 0, -fabPadding); specsLayout.setPadding(0, 0, 0, fabPadding); ValueAnimator valueAnimator = ValueAnimator.ofInt(detailsViewGroup.getPaddingTop(), size.getHeight()); valueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); valueAnimator.setDuration(animationDuration); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { detailsViewGroup.setPadding(sidePadding, (Integer) valueAnimator.getAnimatedValue(), sidePadding, detailsViewGroup.getPaddingBottom()); } }); valueAnimator.start(); }
From source file:bottombar.BottomBarTab.java
void updateWidth(float endWidth, boolean animated) { if (!animated) { getLayoutParams().width = (int) endWidth; if (!isActive && badge != null) { badge.adjustPositionAndSize(this); badge.show();/*ww w. j a v a 2s. c om*/ } return; } float start = getWidth(); ValueAnimator animator = ValueAnimator.ofFloat(start, endWidth); animator.setDuration(150); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { ViewGroup.LayoutParams params = getLayoutParams(); if (params == null) return; params.width = Math.round((float) animator.getAnimatedValue()); setLayoutParams(params); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (!isActive && badge != null) { badge.adjustPositionAndSize(BottomBarTab.this); badge.show(); } } }); animator.start(); }
From source file:com.taobao.weex.ui.view.refresh.core.WXSwipeLayout.java
/** * Reset refresh state//www .jav a2 s .c o m * @param headerViewHeight */ private void resetHeaderView(int headerViewHeight) { headerView.stopAnimation(); headerView.setStartEndTrim(0, 0.75f); ValueAnimator animator = ValueAnimator.ofFloat(headerViewHeight, 0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { LayoutParams lp = (LayoutParams) headerView.getLayoutParams(); lp.height = (int) ((Float) animation.getAnimatedValue()).floatValue(); headerView.setLayoutParams(lp); moveTargetView(lp.height); } }); animator.addListener(new WXRefreshAnimatorListener() { @Override public void onAnimationEnd(Animator animation) { resetRefreshState(); } }); animator.setDuration(300); animator.start(); }
From source file:com.taobao.weex.ui.view.refresh.core.WXSwipeLayout.java
/** * Reset loadmore state//from w ww . jav a 2 s . c o m * @param headerViewHeight */ private void resetFootView(int headerViewHeight) { footerView.stopAnimation(); footerView.setStartEndTrim(0.5f, 1.25f); ValueAnimator animator = ValueAnimator.ofFloat(headerViewHeight, 0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { LayoutParams lp = (LayoutParams) footerView.getLayoutParams(); lp.height = (int) ((Float) animation.getAnimatedValue()).floatValue(); footerView.setLayoutParams(lp); moveTargetView(-lp.height); } }); animator.addListener(new WXRefreshAnimatorListener() { @Override public void onAnimationEnd(Animator animation) { resetLoadmoreState(); } }); animator.setDuration(300); animator.start(); }
From source file:com.bitants.wally.activities.ImageDetailsActivity.java
private void setupPaddings(final Size size, boolean animate) { int animationDuration = animate ? 300 : 0; final int sidePadding = getResources() .getDimensionPixelSize(R.dimen.activity_details_scrollview_side_padding); int fabPadding = getResources().getDimensionPixelSize(R.dimen.fab_padding_positive); int minimumAllowedHeight = fabPadding; if (size.getHeight() < minimumAllowedHeight) { size.setHeight(size.getHeight()); ValueAnimator valueAnimator = ValueAnimator.ofInt(photoLayoutHolder.getPaddingTop()); valueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); valueAnimator.setDuration(animationDuration); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override// ww w . j a v a2s .c o m public void onAnimationUpdate(ValueAnimator valueAnimator) { photoLayoutHolder.setPadding(0, (Integer) valueAnimator.getAnimatedValue(), 0, 0); } }); valueAnimator.start(); } else { photoLayoutHolder.setPadding(0, 0, 0, 0); } scrollView.setPadding(0, 0, 0, -fabPadding); specsLayout.setPadding(0, 0, 0, fabPadding); ValueAnimator valueAnimator = ValueAnimator.ofInt(detailsViewGroup.getPaddingTop(), size.getHeight()); valueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); valueAnimator.setDuration(animationDuration); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { detailsViewGroup.setPadding(sidePadding, (Integer) valueAnimator.getAnimatedValue(), sidePadding, detailsViewGroup.getPaddingBottom()); } }); valueAnimator.start(); }
From source file:com.tengio.FloatingSearchView.java
private void fadeOutBackground() { ValueAnimator anim = ValueAnimator.ofInt(BACKGROUND_DRAWABLE_ALPHA_SEARCH_FOCUSED, BACKGROUND_DRAWABLE_ALPHA_SEARCH_NOT_FOCUSED); anim.setDuration(BACKGROUND_FADE_ANIM_DURATION); anim.start(); }
From source file:com.nihaskalam.progressbuttonlibrary.CircularProgressButton.java
private void animateIdleStateButtonAfterClick() { int textColorChangeDuration = 10; ObjectAnimator colorAnim = ObjectAnimator.ofInt(this, "textColor", getNormalColor(this.getTextColors()), mIdleStateTextColorAfterClick); colorAnim.setDuration(textColorChangeDuration); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.start();//ww w . j a va2 s .c om ObjectAnimator colorAnim1 = ObjectAnimator.ofInt(this, "textColor", mIdleStateTextColorAfterClick, getNormalColor(this.getTextColors())); colorAnim1.setDuration(0); colorAnim1.setStartDelay(IDLE_STATE_ANIMATION_DURATION_AFTER_CLICK - textColorChangeDuration); colorAnim1.setEvaluator(new ArgbEvaluator()); colorAnim1.setInterpolator(new BounceInterpolator()); colorAnim1.start(); ObjectAnimator bgAnim = ObjectAnimator.ofInt(this, "backgroundColor", getNormalColor(mIdleColorState), mIdleStateBackgroundColorAfterClick); bgAnim.setDuration(0); bgAnim.setEvaluator(new ArgbEvaluator()); bgAnim.start(); int textSizeAnimationDuration = 150; ValueAnimator animator = ValueAnimator.ofFloat(textSize, textSize - textSize / 4); animator.setDuration(textSizeAnimationDuration); animator.setRepeatCount(1); animator.setRepeatMode(ValueAnimator.REVERSE); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedValue = (float) valueAnimator.getAnimatedValue(); setTextSize(animatedValue); } }); animator.start(); }
From source file:xyz.klinker.android.article.view.ElasticDragDismissFrameLayout.java
@Override public void onStopNestedScroll(View child) { if (enabled) { if (Math.abs(totalDrag) >= dragDismissDistance) { dispatchDismissCallback();/* w w w.jav a 2 s .c o m*/ } else { // settle back to natural position if (fastOutSlowInInterpolator == null) { fastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.fast_out_slow_in); } getChildAt(0).animate().translationY(0f).scaleX(1f).scaleY(1f).setDuration(200L) .setInterpolator(fastOutSlowInInterpolator).setListener(null).start(); ValueAnimator animator = null; if (draggingUp) { animator = ValueAnimator.ofFloat(draggingBackground.top, draggingBackground.bottom); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { draggingBackground.top = (float) valueAnimator.getAnimatedValue(); invalidate(); } }); } else if (draggingDown) { animator = ValueAnimator.ofFloat(draggingBackground.bottom, draggingBackground.top); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { draggingBackground.bottom = (float) valueAnimator.getAnimatedValue(); invalidate(); } }); } if (animator != null) { animator.setInterpolator(fastOutSlowInInterpolator); animator.setDuration(200L); animator.start(); } totalDrag = 0; draggingDown = draggingUp = false; dispatchDragCallback(0f, 0f, 0f, 0f); } } }
From source file:com.jsibbold.zoomage.ZoomageView.java
/** * Animate the matrix back to its original position after the user stopped interacting with it. */// w w w . j a v a 2 s . c o m private void animateToStartMatrix() { final Matrix beginMatrix = new Matrix(getImageMatrix()); beginMatrix.getValues(mValues); //difference in current and original values final float xsdiff = startValues[Matrix.MSCALE_X] - mValues[Matrix.MSCALE_X]; final float ysdiff = startValues[Matrix.MSCALE_Y] - mValues[Matrix.MSCALE_Y]; final float xtdiff = startValues[Matrix.MTRANS_X] - mValues[Matrix.MTRANS_X]; final float ytdiff = startValues[Matrix.MTRANS_Y] - mValues[Matrix.MTRANS_Y]; ValueAnimator anim = ValueAnimator.ofFloat(0, 1f); anim.addUpdateListener(new AnimatorUpdateListener() { final Matrix activeMatrix = new Matrix(getImageMatrix()); final float[] values = new float[9]; @Override public void onAnimationUpdate(ValueAnimator animation) { float val = (Float) animation.getAnimatedValue(); activeMatrix.set(beginMatrix); activeMatrix.getValues(values); values[Matrix.MTRANS_X] = values[Matrix.MTRANS_X] + xtdiff * val; values[Matrix.MTRANS_Y] = values[Matrix.MTRANS_Y] + ytdiff * val; values[Matrix.MSCALE_X] = values[Matrix.MSCALE_X] + xsdiff * val; values[Matrix.MSCALE_Y] = values[Matrix.MSCALE_Y] + ysdiff * val; activeMatrix.setValues(values); setImageMatrix(activeMatrix); } }); anim.setDuration(RESET_DURATION); anim.start(); }