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.android.gallery3d.filtershow.imageshow.ImageShow.java
private void startAnimTranslation(int fromX, int toX, int fromY, int toY, int delay) { if (fromX == toX && fromY == toY) { return;//from w ww . ja v a2 s .c o m } if (mAnimatorTranslateX != null) { mAnimatorTranslateX.cancel(); } if (mAnimatorTranslateY != null) { mAnimatorTranslateY.cancel(); } mAnimatorTranslateX = ValueAnimator.ofInt(fromX, toX); mAnimatorTranslateY = ValueAnimator.ofInt(fromY, toY); mAnimatorTranslateX.setDuration(delay); mAnimatorTranslateY.setDuration(delay); mAnimatorTranslateX.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Point translation = MasterImage.getImage().getTranslation(); translation.x = (Integer) animation.getAnimatedValue(); MasterImage.getImage().setTranslation(translation); invalidate(); } }); mAnimatorTranslateY.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Point translation = MasterImage.getImage().getTranslation(); translation.y = (Integer) animation.getAnimatedValue(); MasterImage.getImage().setTranslation(translation); invalidate(); } }); mAnimatorTranslateX.start(); mAnimatorTranslateY.start(); }
From source file:org.mythtv.client.ui.BackendStatusFragment.java
private void animateCardLinearLayout(final LinearLayout linearLayout, long startDelay) { linearLayout.setAlpha(1);/* w w w.j a v a 2 s . c om*/ // animator that translates linearlayout AnimatorUpdateListener translationAnimatorListener = new AnimatorUpdateListener() { /* (non-Javadoc) * @see android.animation.ValueAnimator.AnimatorUpdateListener#onAnimationUpdate(android.animation.ValueAnimator) */ @Override public void onAnimationUpdate(ValueAnimator animation) { Float w = (Float) animation.getAnimatedValue(); linearLayout.setTranslationY(w); } }; ValueAnimator scaleAnimator = ValueAnimator.ofFloat(linearLayout.getTranslationY(), 0f); scaleAnimator.setDuration(500); scaleAnimator.setRepeatCount(0); scaleAnimator.setStartDelay(startDelay); scaleAnimator.addUpdateListener(translationAnimatorListener); scaleAnimator.start(); }
From source file:com.musenkishi.wally.activities.ImageDetailsActivity.java
/** * Animations animations animations./* w w w.j ava2s . c o m*/ */ private void toggleZoomImage() { int animationDuration = 400; if (isInFullscreen()) { scrollView.smoothScrollTo(0, (Integer) scrollView.getTag()); photoViewAttacher.setScale(1.0f, true); } else { scrollView.setTag(scrollView.getScrollY()); scrollView.smoothScrollTo(0, 0); } if (getSupportActionBar() != null) { getToolbar().animate().translationY(isInFullscreen() ? 0.0f : -getToolbar().getMeasuredHeight()) .alpha(isInFullscreen() ? 1.0f : 0.0f).setDuration(500) .setInterpolator(new EaseInOutBezierInterpolator()).start(); } findViewById(R.id.image_details_protective_shadow).animate().alpha(isInFullscreen() ? 1.0f : 0.0f) .setDuration(500).setInterpolator(new EaseInOutBezierInterpolator()).start(); int minimumAllowedHeight = getToolbar().getMeasuredHeight() + getResources().getDimensionPixelSize(R.dimen.fab_padding_positive); if (imageSize.getHeight() < minimumAllowedHeight) { int topFrom; int topTo; if (isInFullscreen()) { topFrom = 0; topTo = getToolbar().getMeasuredHeight(); } else { topFrom = photoLayoutHolder.getPaddingTop(); topTo = 0; } ValueAnimator topValueAnimator = ValueAnimator.ofInt(topFrom, topTo); topValueAnimator.setDuration(animationDuration); topValueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); topValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); photoLayoutHolder.setPadding(photoLayoutHolder.getPaddingLeft(), val, photoLayoutHolder.getPaddingRight(), photoLayoutHolder.getPaddingBottom()); } }); topValueAnimator.start(); } if (photoLayoutHolder.getTranslationY() > 0.0f) { photoLayoutHolder.animate().translationY(0.0f).setInterpolator(new EaseInOutBezierInterpolator()) .setDuration(animationDuration).start(); } WindowManager win = getWindowManager(); Display d = win.getDefaultDisplay(); int from = photoView.getMeasuredHeight(); int to = isInFullscreen() ? imageSize.getHeight() : d.getHeight(); ValueAnimator valueAnimator = ValueAnimator.ofInt(from, to); valueAnimator.setDuration(animationDuration); valueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); RelativeLayout.LayoutParams toolbarParams = (RelativeLayout.LayoutParams) photoView .getLayoutParams(); toolbarParams.height = val; photoView.setLayoutParams(toolbarParams); } }); valueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { photoViewAttacher.setZoomable(true); photoView.setZoomable(true); photoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float v, float v2) { toggleZoomImage(); } }); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); valueAnimator.start(); int scrollTo = isInFullscreen() ? 0 : d.getHeight(); scrollView.animate().y(scrollTo).setDuration(animationDuration) .setInterpolator(new EaseInOutBezierInterpolator()).start(); isInFullscreen = !isInFullscreen; }
From source file:ticwear.design.widget.CollapsingToolbarLayout.java
private void animateScrim(int targetAlpha) { ensureToolbar();//from w w w .ja v a 2 s . c om if (mScrimAnimator == null) { mScrimAnimator = new ValueAnimator(); mScrimAnimator.setDuration(SCRIM_ANIMATION_DURATION); mScrimAnimator .setInterpolator(targetAlpha > mScrimAlpha ? AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR : AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR); mScrimAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { setScrimAlpha((int) animator.getAnimatedValue()); } }); } else if (mScrimAnimator.isRunning()) { mScrimAnimator.cancel(); } mScrimAnimator.setIntValues(mScrimAlpha, targetAlpha); mScrimAnimator.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();/*from www . j a v a 2 s. co m*/ } 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.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();// w w w . j a v a2 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:com.wanderingcan.floatingactionmenu.FloatingActionMenu.java
private void initBackgroundDimAnimation() { final int maxAlpha = Color.alpha(mBackgroundColor); final int red = Color.red(mBackgroundColor); final int green = Color.green(mBackgroundColor); final int blue = Color.blue(mBackgroundColor); mShowBackgroundAnimator = ValueAnimator.ofInt(0, maxAlpha); mShowBackgroundAnimator.setDuration(mAnimationDuration); mShowBackgroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w w w.jav a 2 s .c o m public void onAnimationUpdate(ValueAnimator animation) { Integer alpha = (Integer) animation.getAnimatedValue(); setBackgroundColor(Color.argb(alpha, red, green, blue)); } }); mHideBackgroundAnimator = ValueAnimator.ofInt(maxAlpha, 0); mHideBackgroundAnimator.setDuration(mAnimationDuration); mHideBackgroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Integer alpha = (Integer) animation.getAnimatedValue(); setBackgroundColor(Color.argb(alpha, red, green, blue)); } }); }
From source file:com.test.xujixiao.xjx.widget.view.swipe_listview.SwipeListViewTouchListener.java
/** * Perform dismiss action//from w ww . j a va 2s . co m * * @param dismissView View * @param dismissPosition Position of list */ protected void performDismiss(final View dismissView, final int dismissPosition, boolean doPendingDismiss) { final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(animationTime); if (doPendingDismiss) { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { --dismissAnimationRefCount; if (dismissAnimationRefCount == 0) { removePendingDismisses(originalHeight); } } }); } 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(); }
From source file:com.bitants.wally.activities.ImageDetailsActivity.java
/** * Animations animations animations.//from w ww .j a va2 s .c o m */ private void toggleZoomImage() { int animationDuration = 400; if (isInFullscreen()) { scrollView.smoothScrollTo(0, (Integer) scrollView.getTag()); if (photoViewAttacher != null) { photoViewAttacher.cleanup(); photoViewAttacher = null; photoView.setScaleType(ImageView.ScaleType.CENTER_CROP); } } else { scrollView.setTag(scrollView.getScrollY()); scrollView.smoothScrollTo(0, 0); if (photoViewAttacher == null) { photoViewAttacher = new PhotoViewAttacher(photoView); photoViewAttacher.setZoomable(true); photoViewAttacher.setScaleType(ImageView.ScaleType.CENTER_CROP); } } if (getSupportActionBar() != null) { getToolbar().animate().translationY(isInFullscreen() ? 0.0f : -getToolbar().getMeasuredHeight()) .alpha(isInFullscreen() ? 1.0f : 0.0f).setDuration(500) .setInterpolator(new EaseInOutBezierInterpolator()).start(); } findViewById(R.id.image_details_protective_shadow).animate().alpha(isInFullscreen() ? 1.0f : 0.0f) .setDuration(500).setInterpolator(new EaseInOutBezierInterpolator()).start(); int minimumAllowedHeight = getToolbar().getMeasuredHeight() + getResources().getDimensionPixelSize(R.dimen.fab_padding_positive); if (imageSize.getHeight() < minimumAllowedHeight) { int topFrom; int topTo; if (isInFullscreen()) { topFrom = 0; topTo = getToolbar().getMeasuredHeight(); } else { topFrom = photoLayoutHolder.getPaddingTop(); topTo = 0; } ValueAnimator topValueAnimator = ValueAnimator.ofInt(topFrom, topTo); topValueAnimator.setDuration(animationDuration); topValueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); topValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); photoLayoutHolder.setPadding(photoLayoutHolder.getPaddingLeft(), val, photoLayoutHolder.getPaddingRight(), photoLayoutHolder.getPaddingBottom()); } }); topValueAnimator.start(); } if (photoLayoutHolder.getTranslationY() != 0.0f) { photoLayoutHolder.animate().translationY(0.0f).setInterpolator(new EaseInOutBezierInterpolator()) .setDuration(animationDuration).start(); } WindowManager win = getWindowManager(); Display d = win.getDefaultDisplay(); int from = photoView.getMeasuredHeight(); int to = isInFullscreen() ? imageSize.getHeight() : d.getHeight(); ValueAnimator valueAnimator = ValueAnimator.ofInt(from, to); valueAnimator.setDuration(animationDuration); valueAnimator.setInterpolator(new EaseInOutBezierInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); RelativeLayout.LayoutParams toolbarParams = (RelativeLayout.LayoutParams) photoView .getLayoutParams(); toolbarParams.height = val; photoView.setLayoutParams(toolbarParams); } }); valueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { if (photoViewAttacher != null) { photoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float v, float v2) { toggleZoomImage(); } }); } } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); valueAnimator.start(); int scrollTo = isInFullscreen() ? 0 : d.getHeight(); scrollView.animate().y(scrollTo).setDuration(animationDuration) .setInterpolator(new EaseInOutBezierInterpolator()).start(); isInFullscreen = !isInFullscreen; }
From source file:com.roughike.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 ava 2s . c o m*/ } 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); } }); // Workaround to avoid using faulty onAnimationEnd() listener postDelayed(new Runnable() { @Override public void run() { if (!isActive && badge != null) { clearAnimation(); badge.adjustPositionAndSize(BottomBarTab.this); badge.show(); } } }, animator.getDuration()); animator.start(); }