List of usage examples for android.animation ValueAnimator getAnimatedValue
public Object getAnimatedValue()
ValueAnimator
when there is just one property being animated. From source file:cn.appsdream.nestrefresh.matetialstyle.WaveView.java
public void startDropAnimation() { // show dropBubble again mDisappearCircleAnimator = ValueAnimator.ofFloat(1.f, 1.f); mDisappearCircleAnimator.setDuration(1); mDisappearCircleAnimator.start();//w ww . j a va 2s . c om mDropCircleAnimator = ValueAnimator.ofFloat(500 * (mWidth / 1440.f), mMaxDropHeight); mDropCircleAnimator.setDuration(DROP_CIRCLE_ANIMATOR_DURATION); mDropCircleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mCurrentCircleCenterY = (float) animation.getAnimatedValue(); ViewCompat.postInvalidateOnAnimation(WaveView.this); } }); mDropCircleAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); mDropCircleAnimator.start(); mDropVertexAnimator = ValueAnimator.ofFloat(MAX_WAVE_HEIGHT * mWidth, mMaxDropHeight - mDropCircleRadius); mDropVertexAnimator.setDuration(DROP_VERTEX_ANIMATION_DURATION); mDropVertexAnimator.addUpdateListener(mAnimatorUpdateListener); mDropVertexAnimator.start(); mDropBounceVerticalAnimator = ValueAnimator.ofFloat(0.f, 1.f); mDropBounceVerticalAnimator.setDuration(DROP_BOUNCE_ANIMATOR_DURATION); mDropBounceVerticalAnimator.addUpdateListener(mAnimatorUpdateListener); mDropBounceVerticalAnimator.setInterpolator(new DropBounceInterpolator()); mDropBounceVerticalAnimator.setStartDelay(DROP_VERTEX_ANIMATION_DURATION); mDropBounceVerticalAnimator.start(); mDropBounceHorizontalAnimator = ValueAnimator.ofFloat(0.f, 1.f); mDropBounceHorizontalAnimator.setDuration(DROP_BOUNCE_ANIMATOR_DURATION); mDropBounceHorizontalAnimator.addUpdateListener(mAnimatorUpdateListener); if (mDropListener != null) mDropBounceHorizontalAnimator.addListener(mDropListener); mDropBounceHorizontalAnimator.setInterpolator(new DropBounceInterpolator()); mDropBounceHorizontalAnimator .setStartDelay((long) (DROP_VERTEX_ANIMATION_DURATION + DROP_BOUNCE_ANIMATOR_DURATION * 0.25)); mDropBounceHorizontalAnimator.start(); }
From source file:com.mikhaellopez.saveinsta.activity.MainActivity.java
private void setThemeColor(int colorFrom, final int colorTo) { // Set Toolbar and NavigationBar color ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/* ww w. ja v a 2s .com*/ public void onAnimationUpdate(ValueAnimator animator) { mToolbar.setBackgroundColor((int) animator.getAnimatedValue()); } }); colorAnimation.start(); // Set Status Bar color ValueAnimator colorAnimationDark = ValueAnimator.ofObject(new ArgbEvaluator(), darkerColor(colorFrom), darkerColor(colorTo)); colorAnimationDark.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor((int) animator.getAnimatedValue()); getWindow().setNavigationBarColor((int) animator.getAnimatedValue()); } } }); colorAnimationDark.start(); // Set Text and icon color int textColorFrom = getTextColorByBackground(colorFrom); int textColorTo = getTextColorByBackground(colorTo); if (textColorFrom != colorTo) { ValueAnimator colorAnimationText = ValueAnimator.ofObject(new ArgbEvaluator(), textColorFrom, textColorTo); colorAnimationText.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { mToolbarTitle.setTextColor((int) animator.getAnimatedValue()); if (mMenuItem != null) { mMenuItem.setIcon(isColorDark(colorTo) ? ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_info) : ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_info_dark)); } } }); colorAnimationText.start(); } mCurrentDominantColor = colorTo; }
From source file:zhwx.common.view.waveview.WaveView.java
public void startDropAnimation() { // show dropBubble again mDisappearCircleAnimator = ValueAnimator.ofFloat(1.f, 1.f); mDisappearCircleAnimator.setDuration(1); mDisappearCircleAnimator.start();/*from w ww.j a v a 2 s. co m*/ mDropCircleAnimator = ValueAnimator.ofFloat(500 * (mWidth / 1440.f), mMaxDropHeight); mDropCircleAnimator.setDuration(DROP_CIRCLE_ANIMATOR_DURATION); mDropCircleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mCurrentCircleCenterY = (Float) animation.getAnimatedValue(); ViewCompat.postInvalidateOnAnimation(WaveView.this); } }); mDropCircleAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); mDropCircleAnimator.start(); mDropVertexAnimator = ValueAnimator.ofFloat(0.f, mMaxDropHeight - mDropCircleRadius); mDropVertexAnimator.setDuration(DROP_VERTEX_ANIMATION_DURATION); mDropVertexAnimator.addUpdateListener(mAnimatorUpdateListener); mDropVertexAnimator.start(); mDropBounceVerticalAnimator = ValueAnimator.ofFloat(0.f, 1.f); mDropBounceVerticalAnimator.setDuration(DROP_BOUNCE_ANIMATOR_DURATION); mDropBounceVerticalAnimator.addUpdateListener(mAnimatorUpdateListener); mDropBounceVerticalAnimator.setInterpolator(new DropBounceInterpolator()); mDropBounceVerticalAnimator.setStartDelay(DROP_VERTEX_ANIMATION_DURATION); mDropBounceVerticalAnimator.start(); mDropBounceHorizontalAnimator = ValueAnimator.ofFloat(0.f, 1.f); mDropBounceHorizontalAnimator.setDuration(DROP_BOUNCE_ANIMATOR_DURATION); mDropBounceHorizontalAnimator.addUpdateListener(mAnimatorUpdateListener); mDropBounceHorizontalAnimator.setInterpolator(new DropBounceInterpolator()); mDropBounceHorizontalAnimator .setStartDelay((long) (DROP_VERTEX_ANIMATION_DURATION + DROP_BOUNCE_ANIMATOR_DURATION * 0.25)); mDropBounceHorizontalAnimator.start(); }
From source file:com.rks.musicx.misc.utils.Helper.java
/** * Animate view's background color/*from w w w. j a v a 2 s . c om*/ * * @param view * @param colorBg */ public static void animateViews(Context context, View view, int colorBg) { colorAnimation = setAnimator(0xffe5e5e5, colorBg); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { view.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.start(); }
From source file:bottombar.BottomBarTab.java
private void setTopPaddingAnimated(int start, int end) { if (type == Type.TABLET) { return;/*w w w. j av a 2 s . co m*/ } ValueAnimator paddingAnimator = ValueAnimator.ofInt(start, end); paddingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { iconView.setPadding(iconView.getPaddingLeft(), (Integer) animation.getAnimatedValue(), iconView.getPaddingRight(), iconView.getPaddingBottom()); } }); paddingAnimator.setDuration(ANIMATION_DURATION); paddingAnimator.start(); }
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);//from ww w. ja v a 2 s.c o m animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override 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.telenav.nodeflow.NodeFlowLayout.java
/** * perform closing animation for the specified node * * @param node node to be animated//from w w w . java 2s . c om */ private void animateDrillOut(final Node<?> node) { final Node<?> parent = node.getParent(); if (parent.getDepth() > 0) addView(_getHeaderView(node.getParent()), 0);//add parent if (nodeChangeListener != null && node.getParent().getDepth() > 0) nodeChangeListener.onParentNodeOpening(getChildAt(0), node.getParent()); for (int i = 0; i < node.getParent().getChildCount(); ++i) { if (i != node.getIndex()) addView(_getHeaderView(node.getParent().getChildAt(i)), i + (parent.getDepth() > 0 ? 1 : 0)); } final int newIndex = node.getIndex() + (parent.getDepth() > 0 ? 1 : 0); final int aux = parent.getChildCount() + (parent.getDepth() > 0 ? 1 : 0); ValueAnimator animator = ValueAnimator.ofFloat(1); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { for (int i = 0; i < aux; ++i) { if (i < newIndex) { getChildAt(i).setTranslationY(headerHeight * (-newIndex + i) + headerHeight * newIndex * ((Float) animation.getAnimatedValue())); } else if (i > newIndex) { getChildAt(i) .setTranslationY((getHeight() + headerHeight * (i - (newIndex + 1))) - ((getHeight() - (node.getIndex() + 1 + (parent.getDepth() > 0 ? 1 : 0)) * headerHeight) * ((Float) animation.getAnimatedValue()))); } else { getChildAt(newIndex) .setTranslationY(headerHeight * newIndex * ((Float) animation.getAnimatedValue())); } } } }); animator.addListener(new CustomAnimationListener() { @Override public void onAnimationEnd(Animator animator) { activeNode = parent; updateViews(node, false); } }); animator.setDuration(duration); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.start(); animateDrillAlpha(newIndex + 1, aux, 1); }
From source file:ticwear.design.widget.FloatingActionButton.java
public void startDelayConfirmation(long delay, DelayedConfirmationListener listener) { stopDelayConfirmation();/* w w w . j a v a2 s. c o m*/ setProgressMode(CircularProgressDrawable.MODE_DETERMINATE); setProgressPercent(0); setShowProgress(true); setClickable(true); mDelayedConfirmationListener = listener; mDelayedConfirmationAnimator = ValueAnimator.ofFloat(0, 1).setDuration(delay); mDelayedConfirmationAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float progress = (float) animation.getAnimatedValue(); if (getProgressDrawable() != null) { getProgressDrawable().setProgress(progress); } else { stopDelayConfirmation(); } if (progress >= 1) { finishDelayConfirmation(false); } } }); mDelayedConfirmationAnimator.start(); if (mGestureDetector == null) { mGestureDetector = new GestureDetector(getContext(), new SimpleOnGestureListener() { @Override public boolean onSingleTapConfirmed(MotionEvent e) { finishDelayConfirmation(true); return super.onSingleTapConfirmed(e); } }); } }
From source file:com.projecttango.examples.java.modelcorrespondence.ModelCorrespondenceActivity.java
/** * Animate rotation value to show the next point of the model to make the correspondence. *///from ww w. j a v a 2s . c om private void startRotationAnimation(float start, float end) { if (mZRotationAnimator != null) { mZRotationAnimator.cancel(); } mZRotationAnimator = ValueAnimator.ofFloat(start, end); mZRotationAnimator.setDuration(1500); mZRotationAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator animation) { Float value = (Float) animation.getAnimatedValue(); mModelZRotation = value; } }); mZRotationAnimator.start(); }
From source file:com.me.harris.androidanimations._06_touch.swipelistview.SwipeListViewTouchListener.java
/** * Perform dismiss action// ww w. ja v a2 s.co m * @param dismissView View * @param dismissPosition Position of list */ private void performDismiss(final View dismissView, final int dismissPosition) { final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(animationTime); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { --dismissAnimationRefCount; if (dismissAnimationRefCount == 0) { // No active animations, process all pending dismisses. // Sort by descending position Collections.sort(pendingDismisses); int[] dismissPositions = new int[pendingDismisses.size()]; for (int i = pendingDismisses.size() - 1; i >= 0; i--) { dismissPositions[i] = pendingDismisses.get(i).position; } swipeListView.onDismiss(dismissPositions); ViewGroup.LayoutParams lp; for (PendingDismissData pendingDismiss : pendingDismisses) { // Reset view presentation ViewCompat.setAlpha(pendingDismiss.view, 1f); ViewCompat.setTranslationX(pendingDismiss.view, 0); lp = pendingDismiss.view.getLayoutParams(); lp.height = originalHeight; pendingDismiss.view.setLayoutParams(lp); } pendingDismisses.clear(); } } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); pendingDismisses.add(new PendingDismissData(dismissPosition, dismissView)); animator.start(); }