List of usage examples for android.animation ValueAnimator getAnimatedValue
public Object getAnimatedValue()
ValueAnimator
when there is just one property being animated. From source file:com.amaze.carbonfilemanager.ui.views.Indicator.java
private ValueAnimator createMoveSelectedAnimator(final float moveTo, int was, int now, int steps) { // create the actual move animator ValueAnimator moveSelected = ValueAnimator.ofFloat(selectedDotX, moveTo); // also set up a pending retreat anim this starts when the move is 75% complete retreatAnimation = new PendingRetreatAnimator(was, now, steps, now > was ? new RightwardStartPredicate(moveTo - ((moveTo - selectedDotX) * 0.25f)) : new LeftwardStartPredicate(moveTo + ((selectedDotX - moveTo) * 0.25f))); retreatAnimation.addListener(new AnimatorListenerAdapter() { @Override/*from w w w .jav a 2s .c om*/ public void onAnimationEnd(Animator animation) { resetState(); pageChanging = false; } }); moveSelected.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // todo avoid autoboxing selectedDotX = (Float) valueAnimator.getAnimatedValue(); retreatAnimation.startIfNecessary(selectedDotX); postInvalidateOnAnimation(); } }); moveSelected.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { // set a flag so that we continue to draw the unselected dot in the target position // until the selected dot has finished moving into place selectedDotInPosition = false; } @Override public void onAnimationEnd(Animator animation) { // set a flag when anim finishes so that we don't draw both selected & unselected // page dots selectedDotInPosition = true; } }); // slightly delay the start to give the joins a chance to run // unless dot isn't in position yet then don't delay! moveSelected.setStartDelay(selectedDotInPosition ? animDuration / 4L : 0L); moveSelected.setDuration(animDuration * 3L / 4L); moveSelected.setInterpolator(interpolator); return moveSelected; }
From source file:com.lovejjfg.powerrefresh.PowerRefreshLayout.java
private void performAnim(int start, int end, final AnimListener listener) { ValueAnimator animator = ValueAnimator.ofInt(start, end); animator.setDuration(ANIMATION_DURATION).start(); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*w w w. j av a2s . com*/ public void onAnimationUpdate(ValueAnimator animation) { int value = (int) animation.getAnimatedValue(); scrollTo(0, value); postInvalidate(); listener.onGoing(); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); listener.onEnd(); } }); }
From source file:net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.java
/** * Animate the dismissed list item to zero-height and fire the dismiss callback when * all dismissed list item animations have completed. * * @param dismissView The view that has been slided out. * @param listItemView The list item view. This is the whole view of the list item, and not just * the part, that the user swiped. * @param dismissPosition The position of the view inside the list. *//*from w w w . j a v a2 s. c o m*/ private void performDismiss(final View dismissView, final View listItemView, final int dismissPosition) { final ViewGroup.LayoutParams lp = listItemView.getLayoutParams(); final int originalLayoutHeight = lp.height; if (android.os.Build.VERSION.SDK_INT < 12) { mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView, listItemView)); finishDismiss(dismissView, originalLayoutHeight); } else { int originalHeight = listItemView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { finishDismiss(dismissView, originalLayoutHeight); } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); listItemView.setLayoutParams(lp); } }); mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView, listItemView)); animator.start(); } }
From source file:com.filemanager.free.ui.views.Indicator.java
private ValueAnimator createMoveSelectedAnimator(final float moveTo, int was, int now, int steps) { // create the actual move animator ValueAnimator moveSelected = ValueAnimator.ofFloat(selectedDotX, moveTo); // also set up a pending retreat anim this starts when the move is 75% complete retreatAnimation = new PendingRetreatAnimator(was, now, steps, now > was ? new RightwardStartPredicate(moveTo - ((moveTo - selectedDotX) * 0.25f)) : new LeftwardStartPredicate(moveTo + ((selectedDotX - moveTo) * 0.25f))); retreatAnimation.addListener(new AnimatorListenerAdapter() { @Override/*w w w. jav a 2s . c om*/ public void onAnimationEnd(Animator animation) { resetState(); pageChanging = false; } }); moveSelected.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // todo avoid autoboxing selectedDotX = (Float) valueAnimator.getAnimatedValue(); retreatAnimation.startIfNecessary(selectedDotX); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { postInvalidateOnAnimation(); } else { postInvalidate(); } } }); moveSelected.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { // set a flag so that we continue to draw the unselected dot in the target position // until the selected dot has finished moving into place selectedDotInPosition = false; } @Override public void onAnimationEnd(Animator animation) { // set a flag when anim finishes so that we don't draw both selected & unselected // page dots selectedDotInPosition = true; } }); // slightly delay the start to give the joins a chance to run // unless dot isn't in position yet then don't delay! moveSelected.setStartDelay(selectedDotInPosition ? animDuration / 4l : 0l); moveSelected.setDuration(animDuration * 3l / 4l); moveSelected.setInterpolator(interpolator); return moveSelected; }
From source file:com.taobao.weex.ui.view.refresh.core.WXSwipeLayout.java
/** * Reset refresh state// www.j a v a 2 s . co 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/*w w w.j av a2 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.github.shareme.gwsinkpageindicator.library.InkPageIndicator.java
private ValueAnimator createMoveSelectedAnimator(final float moveTo, int was, int now, int steps) { // create the actual move animator ValueAnimator moveSelected = ValueAnimator.ofFloat(selectedDotX, moveTo); // also set up a pending retreat anim this starts when the move is 75% complete retreatAnimation = new PendingRetreatAnimator(was, now, steps, now > was ? new RightwardStartPredicate(moveTo - ((moveTo - selectedDotX) * 0.25f)) : new LeftwardStartPredicate(moveTo + ((selectedDotX - moveTo) * 0.25f))); retreatAnimation.addListener(new AnimatorListenerAdapter() { @Override/* w w w . ja v a 2s . co m*/ public void onAnimationEnd(Animator animation) { resetState(); pageChanging = false; } }); moveSelected.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // todo avoid autoboxing selectedDotX = (Float) valueAnimator.getAnimatedValue(); retreatAnimation.startIfNecessary(selectedDotX); postInvalidateOnAnimation(); } }); moveSelected.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { // set a flag so that we continue to draw the unselected dot in the target position // until the selected dot has finished moving into place selectedDotInPosition = false; } @Override public void onAnimationEnd(Animator animation) { // set a flag when anim finishes so that we don't draw both selected & unselected // page dots selectedDotInPosition = true; } }); // slightly delay the start to give the joins a chance to run // unless dot isn't in position yet then don't delay! moveSelected.setStartDelay(selectedDotInPosition ? animDuration / 4l : 0l); moveSelected.setDuration(animDuration * 3l / 4l); moveSelected.setInterpolator(interpolator); return moveSelected; }
From source file:com.taobao.weex.ui.view.refresh.core.WXSwipeLayout.java
/** * Start Refresh// w w w . j a va 2 s. c om * @param headerViewHeight */ private void startRefresh(int headerViewHeight) { mRefreshing = true; ValueAnimator animator = ValueAnimator.ofFloat(headerViewHeight, refreshViewHeight); 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) { headerView.startAnimation(); //TODO updateLoadText if (onRefreshListener != null) { onRefreshListener.onRefresh(); } } }); animator.setDuration(300); animator.start(); }
From source file:com.taobao.weex.ui.view.refresh.core.WXSwipeLayout.java
/** * Start loadmore//from w ww .j av a 2s . com * @param headerViewHeight */ private void startLoadmore(int headerViewHeight) { mRefreshing = true; ValueAnimator animator = ValueAnimator.ofFloat(headerViewHeight, loadingViewHeight); 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) { footerView.startAnimation(); //TODO updateLoadText if (onLoadingListener != null) { onLoadingListener.onLoading(); } } }); animator.setDuration(300); animator.start(); }
From source file:com.heinrichreimersoftware.materialintro.view.InkPageIndicator.java
private ValueAnimator createMoveSelectedAnimator(final float moveTo, int was, int now, int steps) { // create the actual move animator ValueAnimator moveSelected = ValueAnimator.ofFloat(selectedDotX, moveTo); // also set up a pending retreat anim this starts when the move is 75% complete retreatAnimation = new PendingRetreatAnimator(was, now, steps, now > was ? new RightwardStartPredicate(moveTo - ((moveTo - selectedDotX) * 0.25f)) : new LeftwardStartPredicate(moveTo + ((selectedDotX - moveTo) * 0.25f))); retreatAnimation.addListener(new AnimatorListenerAdapter() { @Override/*from w w w .j a v a 2 s . c o m*/ public void onAnimationEnd(Animator animation) { resetState(); pageChanging = false; } }); moveSelected.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { selectedDotX = (Float) valueAnimator.getAnimatedValue(); retreatAnimation.startIfNecessary(selectedDotX); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { postInvalidateOnAnimation(); } else { postInvalidate(); } } }); moveSelected.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { // set a flag so that we continue to draw the unselected dot in the target position // until the selected dot has finished moving into place selectedDotInPosition = false; } @Override public void onAnimationEnd(Animator animation) { // set a flag when anim finishes so that we don't draw both selected & unselected // page dots selectedDotInPosition = true; } }); // slightly delay the start to give the joins a chance to run // unless dot isn't in position yet then don't delay! moveSelected.setStartDelay(selectedDotInPosition ? animDuration / 4L : 0L); moveSelected.setDuration(animDuration * 3L / 4L); moveSelected.setInterpolator(interpolator); return moveSelected; }