List of usage examples for android.animation Animator setInterpolator
public abstract void setInterpolator(TimeInterpolator value);
From source file:com.stasbar.knowyourself.timer.TimerFragment.java
/** * @param timerToRemove the timer to be removed during the animation *///from w ww . ja v a 2s . co m private void animateTimerRemove(final Timer timerToRemove) { final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration(); final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0); fadeOut.setDuration(duration); fadeOut.setInterpolator(new DecelerateInterpolator()); fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { LogUtils.d("animateTimerRemove"); DataModel.getDataModel().removeTimer(timerToRemove); } }); final Animator fadeIn = ObjectAnimator.ofFloat(mViewPager, ALPHA, 0, 1); fadeIn.setDuration(duration); fadeIn.setInterpolator(new AccelerateInterpolator()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(fadeOut).before(fadeIn); animatorSet.start(); }
From source file:com.wizardsofm.deskclock.timer.TimerFragment.java
/** * @param toView one of {@link #mTimersView} or {@link #mCreateTimerView} * @param timerToRemove the timer to be removed during the animation; {@code null} if no timer * should be removed/*from w w w . ja v a2 s . c om*/ */ private void animateToView(View toView, final Timer timerToRemove) { if (mCurrentView == toView) { throw new IllegalStateException("toView is already the current view"); } final boolean toTimers = toView == mTimersView; // Avoid double-taps by enabling/disabling the set of buttons active on the new view. updateFab(UpdateType.DISABLE_BUTTONS); final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration(); final Animator rotateFrom = ObjectAnimator.ofFloat(mCurrentView, SCALE_X, 1, 0); rotateFrom.setDuration(duration); rotateFrom.setInterpolator(new DecelerateInterpolator()); rotateFrom.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (timerToRemove != null) { DataModel.getDataModel().removeTimer(timerToRemove); Events.sendTimerEvent(com.wizardsofm.deskclock.R.string.action_delete, com.wizardsofm.deskclock.R.string.label_deskclock); } mCurrentView.setScaleX(1); if (toTimers) { showTimersView(UpdateType.FAB_AND_BUTTONS_SHRINK_AND_EXPAND); } else { showCreateTimerView(UpdateType.FAB_AND_BUTTONS_SHRINK_AND_EXPAND); } } }); final Animator rotateTo = ObjectAnimator.ofFloat(toView, SCALE_X, 0, 1); rotateTo.setDuration(duration); rotateTo.setInterpolator(new AccelerateInterpolator()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(rotateFrom).before(rotateTo); animatorSet.start(); }
From source file:com.android.deskclock.timer.TimerFragment.java
/** * @param timerToRemove the timer to be removed during the animation *//*from www. j a v a 2 s . c o m*/ private void animateTimerRemove(final Timer timerToRemove) { final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0); fadeOut.setDuration(mShortAnimationDuration); fadeOut.setInterpolator(new DecelerateInterpolator()); fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { DataModel.getDataModel().removeTimer(timerToRemove); Events.sendTimerEvent(R.string.action_delete, R.string.label_deskclock); } }); final Animator fadeIn = ObjectAnimator.ofFloat(mViewPager, ALPHA, 0, 1); fadeIn.setDuration(mShortAnimationDuration); fadeIn.setInterpolator(new AccelerateInterpolator()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(fadeOut).before(fadeIn); animatorSet.start(); }
From source file:com.stasbar.knowyourself.timer.TimerFragment.java
/** * @param toView one of {@link #mTimersView} or {@link #mCreateTimerView} * @param timerToRemove the timer to be removed during the animation; {@code null} if no timer * should be removed *//*from ww w. j av a2 s .c o m*/ private void animateToView(View toView, final Timer timerToRemove) { if (mCurrentView == toView) { return; } final boolean toTimers = toView == mTimersView; final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration(); final Animator rotateFrom = ObjectAnimator.ofFloat(mCurrentView, SCALE_X, 1, 0); rotateFrom.setDuration(duration); rotateFrom.setInterpolator(new DecelerateInterpolator()); rotateFrom.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (timerToRemove != null) { DataModel.getDataModel().removeTimer(timerToRemove); ((MainActivity) getActivity()).stopActivity(activityItem, timerToRemove); } mCurrentView.setScaleX(1); if (toTimers) { showTimersView(); } else { showCreateTimerView(); } } }); final Animator rotateTo = ObjectAnimator.ofFloat(toView, SCALE_X, 0, 1); rotateTo.setDuration(duration); rotateTo.setInterpolator(new AccelerateInterpolator()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(rotateFrom).before(rotateTo); animatorSet.start(); }
From source file:io.plaidapp.ui.SearchActivity.java
@OnClick(R.id.fab) protected void save() { // show the save confirmation bubble fab.setVisibility(View.INVISIBLE); confirmSaveContainer.setVisibility(View.VISIBLE); resultsScrim.setVisibility(View.VISIBLE); // expand it once it's been measured and show a scrim over the search results confirmSaveContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override// ww w . j a va2 s.c o m public boolean onPreDraw() { // expand the confirmation confirmSaveContainer.getViewTreeObserver().removeOnPreDrawListener(this); Animator reveal = ViewAnimationUtils.createCircularReveal(confirmSaveContainer, confirmSaveContainer.getWidth() / 2, confirmSaveContainer.getHeight() / 2, fab.getWidth() / 2, confirmSaveContainer.getWidth() / 2); reveal.setDuration(250L); reveal.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)); reveal.start(); // show the scrim int centerX = (fab.getLeft() + fab.getRight()) / 2; int centerY = (fab.getTop() + fab.getBottom()) / 2; Animator revealScrim = ViewAnimationUtils.createCircularReveal(resultsScrim, centerX, centerY, 0, (float) Math.hypot(centerX, centerY)); revealScrim.setDuration(400L); revealScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); revealScrim.start(); ObjectAnimator fadeInScrim = ObjectAnimator.ofArgb(resultsScrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim)); fadeInScrim.setDuration(800L); fadeInScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); fadeInScrim.start(); // ease in the checkboxes saveDribbble.setAlpha(0.6f); saveDribbble.setTranslationY(saveDribbble.getHeight() * 0.4f); saveDribbble.animate().alpha(1f).translationY(0f).setDuration(200L).setInterpolator(AnimationUtils .loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); saveDesignerNews.setAlpha(0.6f); saveDesignerNews.setTranslationY(saveDesignerNews.getHeight() * 0.5f); saveDesignerNews.animate().alpha(1f).translationY(0f).setDuration(200L) .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); return false; } }); }
From source file:com.android.deskclock.alarms.AlarmActivity.java
private Animator getAlertAnimator(final View source, final int titleResId, final String infoText, final String accessibilityText, final int revealColor, final int backgroundColor) { final ViewGroup containerView = (ViewGroup) findViewById(android.R.id.content); final Rect sourceBounds = new Rect(0, 0, source.getHeight(), source.getWidth()); containerView.offsetDescendantRectToMyCoords(source, sourceBounds); final int centerX = sourceBounds.centerX(); final int centerY = sourceBounds.centerY(); final int xMax = Math.max(centerX, containerView.getWidth() - centerX); final int yMax = Math.max(centerY, containerView.getHeight() - centerY); final float startRadius = Math.max(sourceBounds.width(), sourceBounds.height()) / 2.0f; final float endRadius = (float) Math.sqrt(xMax * xMax + yMax * yMax); final CircleView revealView = new CircleView(this).setCenterX(centerX).setCenterY(centerY) .setFillColor(revealColor);//from w w w . ja v a 2 s . c o m containerView.addView(revealView); // TODO: Fade out source icon over the reveal (like LOLLIPOP version). final Animator revealAnimator = ObjectAnimator.ofFloat(revealView, CircleView.RADIUS, startRadius, endRadius); revealAnimator.setDuration(ALERT_REVEAL_DURATION_MILLIS); revealAnimator.setInterpolator(REVEAL_INTERPOLATOR); revealAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mAlertView.setVisibility(View.VISIBLE); mAlertTitleView.setText(titleResId); if (infoText != null) { mAlertInfoView.setText(infoText); mAlertInfoView.setVisibility(View.VISIBLE); } mContentView.setVisibility(View.GONE); getWindow().setBackgroundDrawable(new ColorDrawable(backgroundColor)); } }); final ValueAnimator fadeAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); fadeAnimator.setDuration(ALERT_FADE_DURATION_MILLIS); fadeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { containerView.removeView(revealView); } }); final AnimatorSet alertAnimator = new AnimatorSet(); alertAnimator.play(revealAnimator).before(fadeAnimator); alertAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mAlertView.announceForAccessibility(accessibilityText); mHandler.postDelayed(new Runnable() { @Override public void run() { finish(); } }, ALERT_DISMISS_DELAY_MILLIS); } }); return alertAnimator; }
From source file:com.betterAlarm.deskclock.timer.TimerFragment.java
private Animator getRotateFromAnimator(View view) { final Animator animator = new ObjectAnimator().ofFloat(view, View.SCALE_X, 1.0f, 0.0f); animator.setDuration(ROTATE_ANIM_DURATION_MILIS); animator.setInterpolator(DECELERATE_INTERPOLATOR); return animator; }
From source file:com.betterAlarm.deskclock.timer.TimerFragment.java
private Animator getRotateToAnimator(View view) { final Animator animator = new ObjectAnimator().ofFloat(view, View.SCALE_X, 0.0f, 1.0f); animator.setDuration(ROTATE_ANIM_DURATION_MILIS); animator.setInterpolator(ACCELERATE_INTERPOLATOR); return animator; }
From source file:com.onyx.deskclock.deskclock.alarms.AlarmActivity.java
private Animator getAlertAnimator(final View source, final int titleResId, final String infoText, final String accessibilityText, final int revealColor, final int backgroundColor) { final ViewGroup containerView = (ViewGroup) findViewById(android.R.id.content); final Rect sourceBounds = new Rect(0, 0, source.getHeight(), source.getWidth()); containerView.offsetDescendantRectToMyCoords(source, sourceBounds); final int centerX = sourceBounds.centerX(); final int centerY = sourceBounds.centerY(); final int xMax = Math.max(centerX, containerView.getWidth() - centerX); final int yMax = Math.max(centerY, containerView.getHeight() - centerY); final float startRadius = Math.max(sourceBounds.width(), sourceBounds.height()) / 2.0f; final float endRadius = (float) Math.sqrt(xMax * xMax + yMax * yMax); final CircleView revealView = new CircleView(this).setCenterX(centerX).setCenterY(centerY) .setFillColor(revealColor);//from w w w. ja va 2 s. c o m containerView.addView(revealView); // TODO: Fade out source icon over the reveal (like LOLLIPOP version). final Animator revealAnimator = ObjectAnimator.ofFloat(revealView, CircleView.RADIUS, startRadius, endRadius); revealAnimator.setDuration(ALERT_REVEAL_DURATION_MILLIS); revealAnimator.setInterpolator(REVEAL_INTERPOLATOR); revealAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mAlertView.setVisibility(View.VISIBLE); mAlertTitleView.setText(titleResId); if (infoText != null) { mAlertInfoView.setText(infoText); mAlertInfoView.setVisibility(View.VISIBLE); } mContentView.setVisibility(View.GONE); getWindow().setBackgroundDrawable(new ColorDrawable(backgroundColor)); } }); final ValueAnimator fadeAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); fadeAnimator.setDuration(ALERT_FADE_DURATION_MILLIS); fadeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { containerView.removeView(revealView); } }); final AnimatorSet alertAnimator = new AnimatorSet(); alertAnimator.play(revealAnimator).before(fadeAnimator); alertAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { if (Build.VERSION.SDK_INT >= 16) { mAlertView.announceForAccessibility(accessibilityText); } mHandler.postDelayed(new Runnable() { @Override public void run() { finish(); } }, ALERT_DISMISS_DELAY_MILLIS); } }); return alertAnimator; }
From source file:com.android.deskclock.timer.TimerFragment.java
/** * @param toView one of {@link #mTimersView} or {@link #mCreateTimerView} * @param timerToRemove the timer to be removed during the animation; {@code null} if no timer * should be removed/*from w ww. j ava 2s . c o m*/ */ private void animateToView(View toView, final Timer timerToRemove) { if (mCurrentView == toView) { throw new IllegalStateException("toView is already the current view"); } final boolean toTimers = toView == mTimersView; // Avoid double-taps by enabling/disabling the set of buttons active on the new view. mLeftButton.setEnabled(toTimers); mRightButton.setEnabled(toTimers); mCancelCreateButton.setEnabled(!toTimers); final Animator rotateFrom = ObjectAnimator.ofFloat(mCurrentView, SCALE_X, 1, 0); rotateFrom.setDuration(mShortAnimationDuration); rotateFrom.setInterpolator(new DecelerateInterpolator()); rotateFrom.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (timerToRemove != null) { DataModel.getDataModel().removeTimer(timerToRemove); Events.sendTimerEvent(R.string.action_delete, R.string.label_deskclock); } mCurrentView.setScaleX(1); if (toTimers) { showTimersView(); } else { showCreateTimerView(); } } }); final Animator rotateTo = ObjectAnimator.ofFloat(toView, SCALE_X, 0, 1); rotateTo.setDuration(mShortAnimationDuration); rotateTo.setInterpolator(new AccelerateInterpolator()); final float preScale = toTimers ? 0 : 1; final float postScale = toTimers ? 1 : 0; final Animator fabAnimator = getScaleAnimator(mFab, preScale, postScale); final Animator leftButtonAnimator = getScaleAnimator(mLeftButton, preScale, postScale); final Animator rightButtonAnimator = getScaleAnimator(mRightButton, preScale, postScale); final AnimatorSet buttons = new AnimatorSet(); buttons.setDuration(toTimers ? mMediumAnimationDuration : mShortAnimationDuration); buttons.play(leftButtonAnimator).with(rightButtonAnimator).with(fabAnimator); buttons.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLeftButton.setVisibility(toTimers ? VISIBLE : INVISIBLE); mRightButton.setVisibility(toTimers ? VISIBLE : INVISIBLE); mFab.setScaleX(1); mFab.setScaleY(1); mLeftButton.setScaleX(1); mLeftButton.setScaleY(1); mRightButton.setScaleX(1); mRightButton.setScaleY(1); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(rotateFrom).before(rotateTo).with(buttons); animatorSet.start(); }