List of usage examples for android.animation ValueAnimator start
@Override public void start()
From source file:org.xbmc.kore.ui.generic.NavigationDrawerFragment.java
/** * Animates the drawerToggle from the hamburger to an arrow or vice versa * @param toArrow True, hamburger to arrow, false arrow to hamburger *//*w ww.j av a 2s. com*/ public void animateDrawerToggle(final boolean toArrow) { float start = toArrow ? 0.0f : 1.0f, end = 1.0f - start; ValueAnimator anim = ValueAnimator.ofFloat(start, end); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float slideOffset = (Float) valueAnimator.getAnimatedValue(); mDrawerToggle.onDrawerSlide(mDrawerLayout, slideOffset); } }); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(500); anim.start(); }
From source file:xyz.klinker.android.article.ArticleScrollListener.java
private void animateBackgroundColor(int from, int to, Interpolator interpolator) { final ValueAnimator anim = new ValueAnimator(); anim.setIntValues(from, to);//from w w w . j a va 2 s . c om anim.setEvaluator(new ArgbEvaluator()); anim.setInterpolator(interpolator); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { toolbar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); statusBar.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); } }); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); isUpdatingBackground = false; } }); anim.setDuration(ANIMATION_DURATION); anim.start(); isUpdatingBackground = true; }
From source file:me.lizheng.deckview.views.DeckChildView.java
/** * Animates the deletion of this task view *//*w ww.j av a 2s .c o m*/ void startDeleteTaskAnimation(final Runnable r) { // Disabling clipping with the stack while the view is animating away setClipViewInStack(false); ValueAnimator anim = ObjectAnimator.ofFloat(this, View.TRANSLATION_X, getSize()); anim.setInterpolator(new LinearInterpolator()); anim.setDuration(100); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setClipViewInStack(true); setTouchEnabled(true); r.run(); } }); anim.start(); }
From source file:com.bitants.wally.fragments.ImageZoomFragment.java
private void animateOut() { ValueAnimator animWidth = ValueAnimator.ofInt(zoomableImageView.getMeasuredWidth(), rect.right); animWidth.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from www . j a va 2 s. c o m*/ public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams(); layoutParams.width = val; zoomableImageView.setLayoutParams(layoutParams); } }); animWidth.setDuration(500); animWidth.start(); ValueAnimator animHeight = ValueAnimator.ofInt(zoomableImageView.getMeasuredHeight(), rect.bottom); animHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { int val = (Integer) valueAnimator.getAnimatedValue(); ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams(); layoutParams.height = val; zoomableImageView.setLayoutParams(layoutParams); } }); animHeight.setDuration(500); animHeight.start(); if (statusBarHeightCorrection > 0) { zoomableImageView.animate().y(-statusBarHeightCorrection).setDuration(300).start(); } zoomableImageView.animate().alpha(0.0f).setDuration(500).start(); }
From source file:com.awt.supark.LayoutHandler.java
public void pullDown(final MainActivity act) { act.animInProgress = true;/* w w w. j a v a2s .com*/ act.CarHandler.updateLicense(act); // ****** BUTTON AND LAYOUT PULL DOWN ANIMATION // Declaring animator ValueAnimator animation = ValueAnimator.ofFloat(0f, 1f); // Sets the animation properties animation.setDuration(act.layoutPullUpDuration); animation.setInterpolator(new AccelerateDecelerateInterpolator()); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); act.tableRowTopHalf.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, value)); act.btnMap.setAlpha(value); act.btnCars.setAlpha(value); act.btnStatistics.setAlpha(value); act.btnEtc.setAlpha(value); } }); animation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { // Starts layout pull down and fade out animation act.otherContent.startAnimation(act.anim_slide_down_fade_out); act.anim_slide_down_fade_out.setFillAfter(true); // Makes layout invisible act.otherContent.setVisibility(View.GONE); } @Override public void onAnimationEnd(Animator animation) { act.contentLinear.setVisibility(View.VISIBLE); // ****** UI ELEMENTS FADE IN ANIMATION ****** // Declaring animator ValueAnimator nextAnimation = ValueAnimator.ofFloat(0.17f, 1f); // Sets the animation properties nextAnimation.setDuration(act.layoutFadeInDuration); nextAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); act.contentLinear.setAlpha(value); } }); nextAnimation.start(); act.pullUp = false; act.openedLayout = 0; act.animInProgress = false; FragmentTransaction transaction = act.fragmentManager.beginTransaction(); transaction.remove(act.fragmentManager.findFragmentById(R.id.otherContent)); transaction.commit(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animation.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/*from w w w.jav a 2 s . c om*/ 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:org.digitalcampus.oppia.activity.DownloadMediaActivity.java
private void showDownloadMediaMessage() { TranslateAnimation anim = new TranslateAnimation(0, 0, -200, 0); anim.setDuration(900);/* w ww . j a va 2 s.c o m*/ missingMediaContainer.startAnimation(anim); missingMediaContainer.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); ValueAnimator animator = ValueAnimator.ofInt(0, missingMediaContainer.getMeasuredHeight()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { //@Override public void onAnimationUpdate(ValueAnimator valueAnimator) { mediaList.setPadding(0, (Integer) valueAnimator.getAnimatedValue(), 0, 0); mediaList.setSelectionAfterHeaderView(); } }); animator.setStartDelay(200); animator.setDuration(700); animator.start(); }
From source file:org.digitalcampus.oppia.activity.DownloadMediaActivity.java
private void hideDownloadMediaMessage() { TranslateAnimation anim = new TranslateAnimation(0, 0, 0, -200); anim.setDuration(900);//from ww w.ja v a 2 s . c o m missingMediaContainer.startAnimation(anim); missingMediaContainer.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); ValueAnimator animator = ValueAnimator.ofInt(missingMediaContainer.getMeasuredHeight(), 0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { //@Override public void onAnimationUpdate(ValueAnimator valueAnimator) { mediaList.setPadding(0, (Integer) valueAnimator.getAnimatedValue(), 0, 0); mediaList.setSelectionAfterHeaderView(); } }); animator.setStartDelay(0); animator.setDuration(700); animator.start(); missingMediaContainer.setVisibility(View.GONE); }
From source file:com.telenav.nodeflow.NodeFlowLayout.java
/** * perform a fade in animation for showing node content * * @param node active node/*from w ww. ja va 2 s . c o m*/ */ private void fadeIn(final Node<?> node) { ValueAnimator animator = ValueAnimator.ofFloat(1); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { for (int i = getChildCount() - (node.hasChildren() ? node.getChildCount() : 1); i < getChildCount(); ++i) { getChildAt(i).setAlpha(((Float) animation.getAnimatedValue())); } } }); animator.setDuration(duration); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.start(); }
From source file:bottombar.BottomBarTab.java
private void animateColors(int previousColor, int color) { ValueAnimator anim = new ValueAnimator(); anim.setIntValues(previousColor, color); anim.setEvaluator(new ArgbEvaluator()); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/* w ww . j a v a2 s . co m*/ public void onAnimationUpdate(ValueAnimator valueAnimator) { setColors((Integer) valueAnimator.getAnimatedValue()); } }); anim.setDuration(150); anim.start(); }