List of usage examples for android.animation ValueAnimator addUpdateListener
public void addUpdateListener(AnimatorUpdateListener listener)
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 .ja v a 2 s. c o m*/ public void onAnimationUpdate(final ValueAnimator valueAnimator) { ViewGroup.LayoutParams layoutParams = view.getLayoutParams(); layoutParams.height = (Integer) valueAnimator.getAnimatedValue(); view.setLayoutParams(layoutParams); } }); return animator; }
From source file:im.ene.ribbon.FixedActionTabView.java
@Override protected void onStatusChanged(final boolean expanded, final int size, final boolean animate) { if (!animate) { updateLayoutOnAnimation(1, expanded); setIconTranslation(expanded ? 0 : (paddingTopInactive - paddingTopActive)); return;//from w w w .jav a 2 s . c o m } final AnimatorSet set = new AnimatorSet(); set.setDuration(animationDuration); set.setInterpolator(interpolator); final ValueAnimator textScaleAnimator = ObjectAnimator.ofFloat(this, "textScale", expanded ? TEXT_SCALE_ACTIVE : 1); textScaleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator animation) { final float fraction = animation.getAnimatedFraction(); updateLayoutOnAnimation(fraction, expanded); } }); final ValueAnimator iconTranslationAnimator = ObjectAnimator.ofFloat(this, "iconTranslation", expanded ? 0 : (paddingTopInactive - paddingTopActive)); set.playTogether(textScaleAnimator, iconTranslationAnimator); set.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 www . ja v a 2 s . co 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.dmallcott.progressfloatingactionbutton.ProgressView.java
public void setCurrentProgress(int currentProgress, boolean animate) { // If the view is animating no further actions are allowed if (isAnimating) return;/* w w w. j a v a 2 s . co 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.myhexaville.iconanimations.gooey_fab.GooeyFabCompatImpl.java
public void showAnimation() { if (!mIsLargeFab) { if (!mIsExpanded) { mIcon.setAlpha(0f);/*from www . jav a 2 s .c o m*/ } animate().translationYBy(mIsExpanded ? mAnimationTanslationY : -mAnimationTanslationY).setDuration(250) .start(); mIcon.animate().alpha(!mIsExpanded ? 1f : 0f).setDuration(500).start(); mGooeyPart = getGooeyPartHeight(); invalidate(); } else { mIcon.animate().rotationBy(mIsExpanded ? -45 : 45).setDuration(187).start(); ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f).setDuration(187); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float v = (float) animation.getAnimatedValue(); mGooeyPart = getGooeyPartHeight() * v; invalidate(); } }); animator.start(); } new Handler().postDelayed(new Runnable() { @Override public void run() { ValueAnimator animator = ValueAnimator.ofFloat(1f, 0f).setDuration(187); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float v = (float) animation.getAnimatedValue(); mGooeyPart = getGooeyPartHeight() * v; invalidate(); } }); animator.start(); } }, 187); new Handler().postDelayed(new Runnable() { @Override public void run() { mIsExpanded = !mIsExpanded; } }, 250); }
From source file:org.lib.ExpandableLinearLayout.java
private void animateHeight(final View view, final int targetHeight) { if (animatorSet == null) { animatorSet = new AnimatorSet(); animatorSet.setInterpolator(interpolator); animatorSet.setDuration(duration); }/*from w ww .j a v a 2s . c o m*/ final LayoutParams lp = (LayoutParams) view.getLayoutParams(); lp.weight = 0; int height = view.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(height, targetHeight); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { view.getLayoutParams().height = (Integer) valueAnimator.getAnimatedValue(); view.requestLayout(); if (listener != null) { float fraction = targetHeight == 0 ? 1 - valueAnimator.getAnimatedFraction() : valueAnimator.getAnimatedFraction(); listener.onExpansionUpdate(fraction); } } }); animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { if (targetHeight == 0) { view.setVisibility(GONE); } else { lp.height = lp.originalHeight; lp.weight = lp.originalWeight; } } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); animatorSet.playTogether(animator); }
From source file:com.ofalvai.bpinfo.ui.alert.AlertDetailFragment.java
public void updateAlert(final Alert alert) { mAlert = alert;/* w w w . j ava 2 s .c o m*/ mDisplayedRoutes.clear(); mRouteIconsLayout.removeAllViews(); // Updating views displayAlert(alert); // View animations // For some reason, ObjectAnimator doesn't work here (skips animation states, just shows the // last frame), we need to use ValueAnimators. AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(300); animatorSet.setInterpolator(new FastOutSlowInInterpolator()); // We can't measure the TextView's height before a layout happens because of the setText() call // Note: even though displayAlert() was called earlier, the TextView's height is still 0. int heightEstimate = mDescriptionTextView.getLineHeight() * mDescriptionTextView.getLineCount() + 10; ValueAnimator descriptionHeight = ValueAnimator.ofInt(mDescriptionTextView.getHeight(), heightEstimate); descriptionHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mDescriptionTextView.getLayoutParams().height = (int) animation.getAnimatedValue(); mDescriptionTextView.requestLayout(); } }); descriptionHeight.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mDescriptionTextView.setAlpha(1.0f); mDescriptionTextView.setVisibility(View.VISIBLE); } }); ValueAnimator descriptionAlpha = ValueAnimator.ofFloat(0, 1.0f); descriptionAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mDescriptionTextView.setAlpha((float) animation.getAnimatedValue()); } }); ValueAnimator progressHeight = ValueAnimator.ofInt(mProgressBar.getHeight(), 0); progressHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mProgressBar.getLayoutParams().height = (int) animation.getAnimatedValue(); mProgressBar.requestLayout(); } }); progressHeight.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mProgressBar.hide(); } }); animatorSet.playTogether(progressHeight, descriptionHeight, descriptionAlpha); animatorSet.start(); }
From source file:se.frikod.payday.DailyBudgetFragment.java
@TargetApi(11) private void renderBudgetAnimated() { ValueAnimator animation = ValueAnimator.ofFloat((float) currentBudget, (float) budget.dailyBudget); animation.setDuration(500);//from w w w . j a va 2s . c o m animation.addUpdateListener(new AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator a) { renderBudget((Float) a.getAnimatedValue()); } }); animation.start(); }
From source file:com.ymt.demo1.plates.eduPlane.myStudy.MyStudyFragment.java
private void animateToolbar(final float toY) { float layoutTranslationY = ViewHelper.getTranslationY(mInterceptionLayout); if (layoutTranslationY != toY) { ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mInterceptionLayout), toY) .setDuration(200);//www. ja v a2 s . co m animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float translationY = (float) animation.getAnimatedValue(); View infoView = getActivity().findViewById(R.id.personal_info_layout); ViewHelper.setTranslationY(mInterceptionLayout, translationY); ViewHelper.setTranslationY(infoView, translationY); if (translationY < 0) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout .getLayoutParams(); lp.height = (int) (-translationY + getScreenHeight()); mInterceptionLayout.requestLayout(); } } }); animator.start(); } }
From source file:me.lizheng.deckview.views.DeckChildViewHeader.java
/** * Notifies the associated TaskView has been focused. *///from ww w . j a v a 2 s . c om void onTaskViewFocusChanged(boolean focused, boolean animateFocusedState) { // If we are not animating the visible state, just return if (!animateFocusedState) return; boolean isRunning = false; if (mFocusAnimator != null) { isRunning = mFocusAnimator.isRunning(); DVUtils.cancelAnimationWithoutCallbacks(mFocusAnimator); } if (focused) { // Pulse the background color int currentColor = mBackgroundColor; int lightPrimaryColor = getSecondaryColor(mCurrentPrimaryColor, mCurrentPrimaryColorIsDark); ValueAnimator backgroundColor = ValueAnimator.ofObject(new ArgbEvaluator(), currentColor, lightPrimaryColor); backgroundColor.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int color = (int) animation.getAnimatedValue(); mBackgroundColorDrawable.setColor(color); mBackgroundColor = color; } }); backgroundColor.setRepeatCount(ValueAnimator.INFINITE); backgroundColor.setRepeatMode(ValueAnimator.REVERSE); // Pulse the translation ObjectAnimator translation = ObjectAnimator.ofFloat(this, "translationZ", 15f); translation.setRepeatCount(ValueAnimator.INFINITE); translation.setRepeatMode(ValueAnimator.REVERSE); mFocusAnimator = new AnimatorSet(); mFocusAnimator.playTogether(backgroundColor, translation); mFocusAnimator.setStartDelay(750); mFocusAnimator.setDuration(750); mFocusAnimator.start(); } else if (isRunning) { // Restore the background color int currentColor = mBackgroundColor; ValueAnimator backgroundColor = ValueAnimator.ofObject(new ArgbEvaluator(), currentColor, mCurrentPrimaryColor); backgroundColor.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int color = (int) animation.getAnimatedValue(); mBackgroundColorDrawable.setColor(color); mBackgroundColor = color; } }); // Restore the translation ObjectAnimator translation = ObjectAnimator.ofFloat(this, "translationZ", 0f); mFocusAnimator = new AnimatorSet(); mFocusAnimator.playTogether(backgroundColor, translation); mFocusAnimator.setDuration(150); mFocusAnimator.start(); } }