List of usage examples for android.animation ValueAnimator setInterpolator
@Override public void setInterpolator(TimeInterpolator value)
From source file:fr.julienvermet.bugdroid.ui.tablet.AbsBugsMultiPaneFragment.java
public void collapseLeftPane(int speed) { int targetWidth = mMinLeftWidth; ValueAnimator animator = ValueAnimator.ofObject(new WidthEvaluator(mLeftPane), mLeftPane.getWidth(), targetWidth);// w w w.j av a 2 s. com animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); mLeftName.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mLeftView.setVisibility(View.GONE); mIsLeftCollapsed = true; } }); animator.setInterpolator(new DecelerateInterpolator()); animator.setDuration(speed); animator.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/*from w w w .j a va 2 s . 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.geecko.QuickLyric.adapter.IntroScreenSlidePagerAdapter.java
public IntroScreenSlidePagerAdapter(FragmentManager fm, final Activity activity) { super(fm);/* w w w.j a v a 2 s . c o m*/ this.mActivity = activity; mPager = ((ViewPager) mActivity.findViewById(R.id.pager)); mPager.setOnTouchListener(exitTouchListener); if (Build.VERSION.SDK_INT >= 17) rightToLeft = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == 1; if (rightToLeft) { List<Integer> list = Arrays.asList(colors); Collections.reverse(list); colors = (Integer[]) list.toArray(); } ImageButton pagerArrow = ((ImageButton) mActivity.findViewById(R.id.pager_arrow)); Button okButton = ((Button) mActivity.findViewById(R.id.pager_ok)); okButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !Tutorial_5.nlEnabled) { final ViewGroup nlFrame = (ViewGroup) activity.findViewById(R.id.NL_frame); final ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), Color.parseColor("#30000000"), Color.parseColor("#80FFFFFF")); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { nlFrame.setBackgroundColor((int) animation.getAnimatedValue()); } }); colorAnimation.setInterpolator(new LinearOutSlowInInterpolator()); colorAnimation.setRepeatCount(3); colorAnimation.setRepeatMode(ValueAnimator.REVERSE); colorAnimation.setDuration(650L); colorAnimation.start(); } else if (!hasClicked) { exitAction(); hasClicked = true; } } }); pagerArrow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { nextAction(); } }); }
From source file:com.guodong.sun.guodong.widget.ZoomImageView.java
private void startTransform(final int state) { if (mTransfrom == null) { return;/*from w ww .ja va 2 s.co m*/ } ValueAnimator valueAnimator = new ValueAnimator(); valueAnimator.setDuration(300); valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); if (state == STATE_TRANSFORM_IN) { PropertyValuesHolder scaleHolder = PropertyValuesHolder.ofFloat("scale", mTransfrom.startScale, mTransfrom.endScale); PropertyValuesHolder leftHolder = PropertyValuesHolder.ofFloat("left", mTransfrom.startRect.left, mTransfrom.endRect.left); PropertyValuesHolder topHolder = PropertyValuesHolder.ofFloat("top", mTransfrom.startRect.top, mTransfrom.endRect.top); PropertyValuesHolder widthHolder = PropertyValuesHolder.ofFloat("width", mTransfrom.startRect.width, mTransfrom.endRect.width); PropertyValuesHolder heightHolder = PropertyValuesHolder.ofFloat("height", mTransfrom.startRect.height, mTransfrom.endRect.height); PropertyValuesHolder alphaHolder = PropertyValuesHolder.ofInt("alpha", 0, 255); valueAnimator.setValues(scaleHolder, leftHolder, topHolder, widthHolder, heightHolder, alphaHolder); } else { PropertyValuesHolder scaleHolder = PropertyValuesHolder.ofFloat("scale", mTransfrom.endScale, mTransfrom.startScale); PropertyValuesHolder leftHolder = PropertyValuesHolder.ofFloat("left", mTransfrom.endRect.left, mTransfrom.startRect.left); PropertyValuesHolder topHolder = PropertyValuesHolder.ofFloat("top", mTransfrom.endRect.top, mTransfrom.startRect.top); PropertyValuesHolder widthHolder = PropertyValuesHolder.ofFloat("width", mTransfrom.endRect.width, mTransfrom.startRect.width); PropertyValuesHolder heightHolder = PropertyValuesHolder.ofFloat("height", mTransfrom.endRect.height, mTransfrom.startRect.height); PropertyValuesHolder alphaHolder = PropertyValuesHolder.ofInt("alpha", 255, 0); valueAnimator.setValues(scaleHolder, leftHolder, topHolder, widthHolder, heightHolder, alphaHolder); } valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public synchronized void onAnimationUpdate(ValueAnimator animation) { mTransfrom.scale = (Float) animation.getAnimatedValue("scale"); mTransfrom.rect.left = (Float) animation.getAnimatedValue("left"); mTransfrom.rect.top = (Float) animation.getAnimatedValue("top"); mTransfrom.rect.width = (Float) animation.getAnimatedValue("width"); mTransfrom.rect.height = (Float) animation.getAnimatedValue("height"); mBgAlpha = (Integer) animation.getAnimatedValue("alpha"); invalidate(); ((Activity) getContext()).getWindow().getDecorView().invalidate(); } }); valueAnimator.addListener(new ValueAnimator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { /* * ???center_cropout??center_crop? * ???out???Normal???bug */ // TODO ??? if (state == STATE_TRANSFORM_IN) { mState = STATE_NORMAL; } if (mTransformListener != null) { mTransformListener.onTransformComplete(state); } } @Override public void onAnimationCancel(Animator animation) { } }); valueAnimator.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/*from www. j ava 2s . c om*/ 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.telenav.nodeflow.NodeFlowLayout.java
/** * perform a fade out animation for hiding node content * * @param node active node/*from w w w.j a v a 2 s . co m*/ */ private void fadeOut(final Node<?> node) { ValueAnimator animator = ValueAnimator.ofFloat(1, 0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { for (int i = 1; i < getChildCount(); ++i) { getChildAt(i).setAlpha(((Float) animation.getAnimatedValue())); } } }); animator.addListener(new CustomAnimationListener() { @Override public void onAnimationEnd(Animator animator) { animateDrillOut(node); } }); animator.setDuration(duration / 2); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.start(); }
From source file:arun.com.chromer.browsing.article.view.ElasticDragDismissFrameLayout.java
@Override public void onStopNestedScroll(View child) { if (enabled) { if (Math.abs(totalDrag) >= dragDismissDistance) { dispatchDismissCallback();/*from w ww .j ava2s. 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(valueAnimator -> { draggingBackground.top = (float) valueAnimator.getAnimatedValue(); invalidate(); }); } else if (draggingDown) { animator = ValueAnimator.ofFloat(draggingBackground.bottom, draggingBackground.top); animator.addUpdateListener(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.musenkishi.wally.activities.ImageDetailsActivity.java
/** * Animations animations animations.//from w ww .j a v a2 s.c om */ 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:com.bitants.wally.activities.ImageDetailsActivity.java
/** * Animations animations animations.//from ww w. ja va2 s . c o m * @param visibility if VISIBLE, expands toolbar. */ private void animateToolbar(int visibility) { float from; float to; int toolbarOffset; int fabOffset; if (visibility == View.VISIBLE) { from = 0.0f; to = 1.0f; fabOffset = 200; toolbarOffset = 0; } else { from = 1.0f; to = 0.0f; fabOffset = 0; toolbarOffset = 200; } buttonFullscreen.animate().scaleX(to).scaleY(to).setDuration(400).setStartDelay(fabOffset) .setInterpolator(new EaseInOutBezierInterpolator()).setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { buttonFullscreen.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animator) { } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }).start(); int toolbarFrom; int toolbarTo; if (from > 0.0f) { toolbarFrom = getResources().getDimensionPixelSize(R.dimen.details_toolbar_height); toolbarTo = 0; } else { toolbarFrom = 0; toolbarTo = getResources().getDimensionPixelSize(R.dimen.details_toolbar_height); } ValueAnimator valueAnimator = ValueAnimator.ofInt(toolbarFrom, toolbarTo); valueAnimator.setDuration(400); valueAnimator.setStartDelay(toolbarOffset); 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) toolbar.getLayoutParams(); toolbarParams.height = val; toolbar.setLayoutParams(toolbarParams); } }); valueAnimator.start(); }
From source file:com.bitants.wally.activities.ImageDetailsActivity.java
/** * Animations animations animations./*from ww w. jav a2 s . co 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; }