List of usage examples for android.animation ValueAnimator addUpdateListener
public void addUpdateListener(AnimatorUpdateListener listener)
From source file:com.jsibbold.zoomage.ZoomageView.java
private void animateMatrixIndex(final int index, final float to) { ValueAnimator animator = ValueAnimator.ofFloat(mValues[index], to); animator.addUpdateListener(new AnimatorUpdateListener() { final float[] values = new float[9]; Matrix current = new Matrix(); @Override// w w w . j av a 2 s . c om public void onAnimationUpdate(ValueAnimator animation) { current.set(getImageMatrix()); current.getValues(values); values[index] = (Float) animation.getAnimatedValue(); current.setValues(values); setImageMatrix(current); } }); animator.setDuration(RESET_DURATION); animator.start(); }
From source file:ch.gianulli.flashcards.ui.Flashcard.java
private void expandButtonBar() { mButtonBarShowing = true;//from ww w .ja va2 s .c o m mButtonBar.setVisibility(View.VISIBLE); mButtonBar.setAlpha(0.0f); final int startingHeight = mCardView.getHeight(); final ViewTreeObserver observer = mCardView.getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { // We don't want to continue getting called for every listview drawing. if (observer.isAlive()) { observer.removeOnPreDrawListener(this); } final int endingHeight = mCardView.getHeight(); final int distance = endingHeight - startingHeight; mCardView.getLayoutParams().height = startingHeight; mCardView.requestLayout(); ValueAnimator heightAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(300); heightAnimator.setInterpolator(new DecelerateInterpolator()); heightAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { Float value = (Float) animator.getAnimatedValue(); mCardView.getLayoutParams().height = (int) (value * distance + startingHeight); mCardView.requestLayout(); } }); heightAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCardView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; } }); mButtonBar.setLayerType(View.LAYER_TYPE_HARDWARE, null); ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mButtonBar, "alpha", 0.0f, 1.0f); alphaAnimator.setInterpolator(new DecelerateInterpolator()); alphaAnimator.setDuration(300); alphaAnimator.setStartDelay(100); AnimatorSet set = new AnimatorSet(); set.playTogether(heightAnimator, alphaAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mButtonBar.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } }); set.start(); return false; } }); }
From source file:ca.zadrox.dota2esportticker.ui.TeamDetailActivity.java
private void createCompatReveal() { mHeaderTeamLogo.setVisibility(View.VISIBLE); mHeaderTeamLogo.setImageBitmap(mTeam.logo); mHeaderTeamLogo.setTranslationY(-UIUtils.calculateActionBarSize(this) - mHeaderTeamLogo.getHeight()); mHeaderTeamLogo.animate().translationY(0).setDuration(100) .setInterpolator(new AccelerateDecelerateInterpolator()) .setListener(new Animator.AnimatorListener() { @Override/* w ww . j a va 2 s . co m*/ public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mHeaderTeamName.animate().alpha(1).setDuration(150) .setInterpolator(new AccelerateDecelerateInterpolator()).start(); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), getResources().getColor(R.color.theme_primary), mTeam.palette.getDarkVibrantColor(getResources().getColor(R.color.theme_primary))); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { mHeaderBox.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); colorAnimation.setDuration(150); colorAnimation.start(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }).start(); }
From source file:io.github.trulyfree.easyaspi.MainActivity.java
/** * *//*w w w .j av a 2 s.c o m*/ private void resetConfigReturned() { final ImageView configResponseBlock = (ImageView) findViewById(R.id.block_module_returned); LinearLayout layout = (LinearLayout) findViewById(R.id.module_returned_config); EditText moduleName = (EditText) findViewById(R.id.module_returned_configname); EditText moduleVersion = (EditText) findViewById(R.id.module_returned_configversion); EditText moduleConfigUrl = (EditText) findViewById(R.id.module_returned_configurl); EditText moduleJarUrl = (EditText) findViewById(R.id.module_returned_jarurl); LinearLayout moduleDependencies = (LinearLayout) findViewById(R.id.module_returned_dependencies); Button validate = (Button) findViewById(R.id.module_returned_validate); Button cancel = (Button) findViewById(R.id.module_returned_cancel); moduleName.setText(R.string.module_returned_configname); moduleVersion.setText(R.string.module_returned_configversion); moduleConfigUrl.setText(R.string.module_returned_configurl); moduleJarUrl.setText(R.string.module_returned_jarurl); moduleDependencies.removeAllViewsInLayout(); validate.setOnClickListener(null); cancel.setOnClickListener(null); final int colorFrom = ContextCompat.getColor(MainActivity.this, R.color.colorClear); final int colorTo = ContextCompat.getColor(MainActivity.this, R.color.colorFillingTint); ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo); colorAnimation.setDuration(ANIMATION_DURATION); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { configResponseBlock.setBackgroundColor((Integer) animator.getAnimatedValue()); } }); layout.setClickable(false); configResponseBlock.setVisibility(View.VISIBLE); colorAnimation.start(); }
From source file:com.roughike.bottombar.BottomBarTab.java
private void setTopPaddingAnimated(int start, int end) { if (type == Type.TABLET || isTitleless) { return;//from w w w .ja v a 2 s .c o 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.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 ww.j a v a 2 s. c o m 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:io.github.sin3hz.wifispinnerview.WifiSpinnerDrawable.java
private void setupAnimators() { AnimatorSet set = new AnimatorSet(); for (int i = 0; i < mSpinnerCount; i++) { final int index = i; final ValueAnimator sweepAnimator = ValueAnimator.ofFloat(0, MAX_SWEEP_ANGLE); sweepAnimator.setInterpolator(SWEEP_ANIMATOR_INTERPOLATOR); sweepAnimator.setDuration(mSweepAnimatorDuration); sweepAnimator.setRepeatMode(ValueAnimator.RESTART); sweepAnimator.setRepeatCount(ValueAnimator.INFINITE); sweepAnimator.setStartDelay(index * SWEEP_ANIMATOR_DELAY); sweepAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from ww w .java 2s .c o m public void onAnimationUpdate(ValueAnimator animation) { mSpinners[index].sweepAngle = (float) animation.getAnimatedValue(); mSpinners[index].updatePath(); invalidateSelf(); } }); sweepAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationRepeat(Animator animation) { mSpinners[index].sweepAngleOffset = (mSpinners[index].sweepAngleOffset + MAX_SWEEP_ANGLE) % 360; mSpinners[index].updatePath(); } }); set.playTogether(sweepAnimator); } mSweepAnimator = set; mAngleAnimator = ValueAnimator.ofFloat(0, 360); mAngleAnimator.setInterpolator(ANGLE_ANIMATOR_INTERPOLATOR); mAngleAnimator.setRepeatCount(ValueAnimator.INFINITE); mAngleAnimator.setRepeatMode(ValueAnimator.RESTART); mAngleAnimator.setDuration(ANGLE_ANIMATOR_DURATION); mAngleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mGlobalAngle = (float) animation.getAnimatedValue(); updatePath(); invalidateSelf(); } }); }
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 w w w .j a v a 2 s.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); } }); 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.alimuzaffar.lib.pin.PinEntryEditText.java
private void animateBottomUp(CharSequence text, final int start) { mCharBottom[start] = mLineCoords[start].bottom - mTextBottomPadding; ValueAnimator animUp = ValueAnimator.ofFloat(mCharBottom[start] + getPaint().getTextSize(), mCharBottom[start]);/*from ww w . j a v a 2 s. c o m*/ animUp.setDuration(300); animUp.setInterpolator(new OvershootInterpolator()); animUp.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Float value = (Float) animation.getAnimatedValue(); mCharBottom[start] = value; PinEntryEditText.this.invalidate(); } }); mLastCharPaint.setAlpha(255); ValueAnimator animAlpha = ValueAnimator.ofInt(0, 255); animAlpha.setDuration(300); animAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Integer value = (Integer) animation.getAnimatedValue(); mLastCharPaint.setAlpha(value); } }); AnimatorSet set = new AnimatorSet(); if (text.length() == mMaxLength && mOnPinEnteredListener != null) { set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mOnPinEnteredListener.onPinEntered(getText()); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); } set.playTogether(animUp, animAlpha); set.start(); }
From source file:com.awt.supark.LayoutHandler.java
public void smallButtonPressed(final View view, final MainActivity act) { if (!act.pullUp && !act.pullUpStarted) { // If it isn't already up act.pullUpStarted = true;/*from w w w . jav a 2 s .c o m*/ // Declaring animator ValueAnimator animation = ValueAnimator.ofFloat(1f, 0.17f); // ****** UI ELEMENTS FADING OUT ANIMATION ****** // Sets the animation properties animation.setDuration(act.layoutFadeOutDuration); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); // Fades out contentLinear and all buttons, except the one that is pressed act.contentLinear.setAlpha(value); if (view.getId() != R.id.buttonMap) { act.btnMap.setAlpha(value); } if (view.getId() != R.id.buttonCars) { act.btnCars.setAlpha(value); } if (view.getId() != R.id.buttonStatistics) { act.btnStatistics.setAlpha(value); } if (view.getId() != R.id.buttonEtc) { act.btnEtc.setAlpha(value); } } }); animation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { // Sets the visibility of the other layout and contentlinear act.contentLinear.setVisibility(View.GONE); act.otherContent.setVisibility(View.VISIBLE); // ****** BUTTON PULL UP ANIMATION ****** // Declaring animator ValueAnimator nextAnimation = ValueAnimator.ofFloat(1f, 0f); // Sets the animation properties nextAnimation.setDuration(act.layoutPullUpDuration); nextAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); nextAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); // Sets weight of the two layouts, this makes one smaller and the other bigger act.tableRowTopHalf .setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, value)); act.otherContent.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1 - value)); } }); // ****** LAYOUT PULL UP ANIMATION ****** nextAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { act.otherContentHandler(view); // Takes care of including new views act.otherContent.startAnimation(act.anim_slide_up_fade_in); // Animates the new activity act.pullUp = true; // Changing the pull up status indicator act.pullUpStarted = false; } @Override public void onAnimationCancel(Animator animation) { act.pullUpStarted = false; act.otherContent.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animator animation) { } }); nextAnimation.start(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animation.start(); } else if (view.getId() == act.openedLayout) { act.pullDown(); // If there is a layout already pulled up we have to pull it down } else if (act.pullUp && (act.openedLayout != 0) && !act.pullUpStarted) { act.pullUpStarted = true; // To prevent more than one highlight // Changing highlight from previous to current button ValueAnimator animation = ValueAnimator.ofFloat(0.17f, 1f); animation.setDuration(act.smallButtonHighlightChangeDuration); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); act.findViewById(view.getId()).setAlpha(value); act.findViewById(act.openedLayout).setAlpha(1.17f - value); } }); animation.start(); // Fades out current layout act.otherContent.startAnimation(act.anim_fade_out); act.anim_fade_out.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { act.otherContentHandler(view); // Switches the layout to the new one act.otherContent.startAnimation(act.anim_slide_up_fade_in); // Fades in the new layout act.pullUpStarted = false; } @Override public void onAnimationRepeat(Animation animation) { } }); } }