List of usage examples for android.animation Animator addListener
public void addListener(AnimatorListener listener)
From source file:liam.franco.selene.activities.MainActivity.java
private void animateOpenBottomFabSheet() { if (bottomFabBar != null && bottomFabBar.getVisibility() == View.INVISIBLE) { final int[] xy = ViewUtils.viewCoordinates(fab); Animator animator = ViewAnimationUtils.createCircularReveal(bottomFabBar, (xy[0] + (fab.getMeasuredWidth() >> 1)), -bottomFabBar.getHeight(), UIUtils.convertDpToPixel(56f, App.CONTEXT), Math.max(bottomFabBar.getWidth(), bottomFabBar.getHeight())); animator.setDuration(500);/*from w w w . j av a2 s.co m*/ animator.setStartDelay(7000); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { if (fab != null) { fab.setVisibility(View.GONE); } if (bottomFabBar != null) { bottomFabBar.setVisibility(View.VISIBLE); } } }); animator.start(); } }
From source file:com.fairphone.fplauncher3.Folder.java
private static Animator setupAlphaAnimator(final View v, final float startAlpha, final float endAlpha, final long duration, final long startDelay) { v.setAlpha(startAlpha);/*from w w w .ja v a 2 s . co m*/ Animator animator = LauncherAnimUtils.ofFloat(v, "alpha", startAlpha, endAlpha); animator.setDuration(duration); animator.setStartDelay(startDelay); animator.setInterpolator(new LogDecelerateInterpolator(60, 0)); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // in low power mode the animation doesn't play, so set the end value here v.setAlpha(endAlpha); } }); return animator; }
From source file:com.example.jonas.materialmockups.activities.ExhibitDetailsActivity.java
/** * Hides the audio toolbar./*w w w .j a va 2s . c o m*/ * @return true if the audio toolbar was hidden, false otherwise */ private boolean hideAudioToolbar() { if (mRevealView != null) { int cx = (mRevealView.getLeft() + mRevealView.getRight()); int cy = mRevealView.getTop(); int radius = Math.max(mRevealView.getWidth(), mRevealView.getHeight()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { SupportAnimator animator = ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.setDuration(800); SupportAnimator animator_reverse = animator.reverse(); animator_reverse.addListener(new SupportAnimator.AnimatorListener() { @Override public void onAnimationStart() { } @Override public void onAnimationEnd() { mRevealView.setVisibility(View.INVISIBLE); isAudioToolbarHidden = true; } @Override public void onAnimationCancel() { } @Override public void onAnimationRepeat() { } }); animator_reverse.start(); } else { Animator anim = android.view.ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, radius, 0); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mRevealView.setVisibility(View.INVISIBLE); isAudioToolbarHidden = true; } }); anim.start(); } return true; } return false; }
From source file:com.androidinspain.deskclock.alarms.dataadapter.ExpandedAlarmViewHolder.java
@Override public Animator onAnimateChange(final ViewHolder oldHolder, ViewHolder newHolder, long duration) { if (!(oldHolder instanceof AlarmItemViewHolder) || !(newHolder instanceof AlarmItemViewHolder)) { return null; }//from w w w . j av a 2 s . co m final boolean isExpanding = this == newHolder; AnimatorUtils.setBackgroundAlpha(itemView, isExpanding ? 0 : 255); setChangingViewsAlpha(isExpanding ? 0f : 1f); final Animator changeAnimatorSet = isExpanding ? createExpandingAnimator((AlarmItemViewHolder) oldHolder, duration) : createCollapsingAnimator((AlarmItemViewHolder) newHolder, duration); changeAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { AnimatorUtils.setBackgroundAlpha(itemView, 255); clock.setVisibility(View.VISIBLE); onOff.setVisibility(View.VISIBLE); arrow.setVisibility(View.VISIBLE); arrow.setTranslationY(0f); setChangingViewsAlpha(1f); arrow.jumpDrawablesToCurrentState(); } }); return changeAnimatorSet; }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateChange(@NonNull final ViewHolder oldHolder, @NonNull final ViewHolder newHolder, @NonNull ItemHolderInfo preInfo, @NonNull ItemHolderInfo postInfo) { endAnimation(oldHolder);/* ww w . j ava 2 s . co m*/ endAnimation(newHolder); final long changeDuration = getChangeDuration(); List<Object> payloads = preInfo instanceof PayloadItemHolderInfo ? ((PayloadItemHolderInfo) preInfo).getPayloads() : null; if (oldHolder == newHolder) { final Animator animator = ((OnAnimateChangeListener) newHolder).onAnimateChange(payloads, preInfo.left, preInfo.top, preInfo.right, preInfo.bottom, changeDuration); if (animator == null) { dispatchChangeFinished(newHolder, false); return false; } animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchChangeStarting(newHolder, false); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(newHolder); dispatchChangeFinished(newHolder, false); } }); mChangeAnimatorsList.add(animator); mAnimators.put(newHolder, animator); return true; } else if (!(oldHolder instanceof OnAnimateChangeListener) || !(newHolder instanceof OnAnimateChangeListener)) { // Both holders must implement OnAnimateChangeListener in order to animate. dispatchChangeFinished(oldHolder, true); dispatchChangeFinished(newHolder, true); return false; } final Animator oldChangeAnimator = ((OnAnimateChangeListener) oldHolder).onAnimateChange(oldHolder, newHolder, changeDuration); if (oldChangeAnimator != null) { oldChangeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchChangeStarting(oldHolder, true); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(oldHolder); dispatchChangeFinished(oldHolder, true); } }); mAnimators.put(oldHolder, oldChangeAnimator); mChangeAnimatorsList.add(oldChangeAnimator); } else { dispatchChangeFinished(oldHolder, true); } final Animator newChangeAnimator = ((OnAnimateChangeListener) newHolder).onAnimateChange(oldHolder, newHolder, changeDuration); if (newChangeAnimator != null) { newChangeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchChangeStarting(newHolder, false); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(newHolder); dispatchChangeFinished(newHolder, false); } }); mAnimators.put(newHolder, newChangeAnimator); mChangeAnimatorsList.add(newChangeAnimator); } else { dispatchChangeFinished(newHolder, false); } return true; }
From source file:com.itsronald.widget.IndicatorDotPathView.java
/** * Animation: Retreat an indicator dot to a specified position. * After the animation, the dot will be invisibly moved back to its original position. * * @param retreatingDot The dot that should be animated. * @param toX The horizontal coordinate to which the dot should move (in its own coordinate space). * @param toY The vertical coordinate to which the dot should move (in its own coordinate space). * @param animationDuration How long the movement should take, in milliseconds. * @return An animator that moves the dot when started. *///from ww w . j a v a 2s .c o m @NonNull private Animator retreatDotAnimator(@NonNull final IndicatorDotView retreatingDot, final float toX, final float toY, final long animationDuration) { final Animator dotSlideAnimator = retreatingDot.slideAnimator(toX, toY, animationDuration); final float originalTranslationX = retreatingDot.getTranslationX(); final float originalTranslationY = retreatingDot.getTranslationY(); dotSlideAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { retreatingDot.setVisibility(INVISIBLE); retreatingDot.setTranslationX(originalTranslationX); retreatingDot.setTranslationY(originalTranslationY); } }); return dotSlideAnimator; }
From source file:ca.zadrox.dota2esportticker.ui.TeamDetailActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void createCircularReveal() { mHeaderTeamLogo.setVisibility(View.VISIBLE); mHeaderTeamLogo.setImageBitmap(mTeam.logo); if (mHeaderBox.isAttachedToWindow()) { mHeaderTeamLogo.setTranslationY(-UIUtils.calculateActionBarSize(this) - mHeaderTeamLogo.getHeight()); mHeaderTeamLogo.animate().translationY(0).setDuration(100) .setInterpolator(new AccelerateDecelerateInterpolator()) .setListener(new Animator.AnimatorListener() { @Override// w w w . j a va 2s.c o m public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { int cx = (mHeaderBox.getLeft() + mHeaderBox.getRight()) / 2; int cy = (mHeaderBox.getTop() + mHeaderBox.getBottom()) / 2; int finalRadius = Math.max(mHeaderBox.getWidth(), mHeaderBox.getHeight()); final Animator anim = ViewAnimationUtils.createCircularReveal(mHeaderBox, cx, cy, 0, finalRadius); anim.setDuration(250); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { mHeaderTeamName.setAlpha(1); mHeaderTeamLogo.setImageBitmap(mTeam.logo); mHeaderBox.setBackgroundColor(mTeam.palette .getDarkVibrantColor(getResources().getColor(R.color.theme_primary))); } @Override public void onAnimationEnd(Animator animation) { } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); anim.start(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }).start(); } else { mHeaderTeamName.setAlpha(1); mHeaderTeamLogo.setImageBitmap(mTeam.logo); mHeaderBox.setBackgroundColor( mTeam.palette.getDarkVibrantColor(getResources().getColor(R.color.theme_primary))); } }
From source file:io.github.silencio_app.silencio.MainActivity.java
public void hideGraph(View view) { TextView tview = (TextView) findViewById(R.id.amp); tview.setText(getString(R.string.press_start)); // previously visible view final View myView = findViewById(R.id.graph); // get the center for the clipping circle int cx = myView.getWidth() / 2; int cy = myView.getHeight() / 2; // get the initial radius for the clipping circle float initialRadius = (float) Math.hypot(cx, cy); // create the animation (the final radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, initialRadius, 0); // make the view invisible when the animation is done anim.addListener(new AnimatorListenerAdapter() { @Override/*from w w w.ja va 2 s .c o m*/ public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); // make graph and meter invisible myView.setVisibility(View.INVISIBLE); // db_meter.setVisibility(View.GONE); } }); // start the animation anim.start(); }
From source file:com.itsronald.widget.ViewPagerIndicator.java
@Nullable private Animator pageChangeAnimator(final int lastPageIndex, final int newPageIndex) { final IndicatorDotPathView dotPath = getDotPathForPageChange(lastPageIndex, newPageIndex); final IndicatorDotView lastDot = getDotForPage(lastPageIndex); if (dotPath == null || lastDot == null) { final String warning = dotPath == null ? "dotPath is null!" : "lastDot is null!"; Log.w(TAG, warning);//from w w w. j av a 2 s. co m return null; } final Animator connectPathAnimator = dotPath.connectPathAnimator(); connectPathAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { dotPath.setVisibility(VISIBLE); lastDot.setVisibility(INVISIBLE); } }); final long dotSlideDuration = DOT_SLIDE_ANIM_DURATION; final Animator selectedDotSlideAnimator = selectedDotSlideAnimator(newPageIndex, dotSlideDuration, 0); final int pathDirection = getPathDirectionForPageChange(lastPageIndex, newPageIndex); final Animator retreatPathAnimator = dotPath.retreatConnectedPathAnimator(pathDirection); final Animator dotRevealAnimator = lastDot.revealAnimator(); dotRevealAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dotPath.setVisibility(INVISIBLE); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(connectPathAnimator).before(selectedDotSlideAnimator); animatorSet.play(retreatPathAnimator).after(selectedDotSlideAnimator); animatorSet.play(dotRevealAnimator).with(retreatPathAnimator); return animatorSet; }
From source file:im.ene.lab.attiq.ui.activities.SearchActivity.java
@OnClick({ R.id.scrim, R.id.searchback }) protected void dismiss() { // if we're showing search mRecyclerView, circular hide them if (mResultsContainer.getHeight() > 0) { ViewCompat.animate(mResultsContainer).alpha(0.f).setDuration(400L).setInterpolator(LINEAR_OUT_SLOW_INT) .start();// ww w . j av a 2s. c o m Animator closeResults = ViewAnimationUtils.createCircularReveal(mResultsContainer, mSearchIconCenterX, 0, (float) Math.hypot(mSearchIconCenterX, mResultsContainer.getHeight()), 0f); closeResults.setDuration(500L); closeResults.setInterpolator(LINEAR_OUT_SLOW_INT); closeResults.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mResultsContainer.setVisibility(View.INVISIBLE); } }); closeResults.start(); } // translate the icon to match position in the launching activity ViewCompat.animate(mSearchNavButtonContainer).translationX(mSearchBackDistanceX).alpha(0.f) .setDuration(600L).setInterpolator(LINEAR_OUT_SLOW_INT) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override public void onAnimationEnd(View view) { ActivityCompat.finishAfterTransition(SearchActivity.this); } }).start(); // transform from back icon to search icon mSearchNavButton.setImageResource(R.drawable.ic_search_24dp_black); // clear the background else the touch ripple moves with the translation which looks bad mSearchNavButton.setBackground(null); // fade out the other search chrome ViewCompat.animate(mSearchView).alpha(0f).setStartDelay(0L).setDuration(120L) .setInterpolator(LINEAR_OUT_SLOW_INT).setListener(null).start(); ViewCompat.animate(mSearchBackground).alpha(0f).setStartDelay(300L).setDuration(160L) .setInterpolator(LINEAR_OUT_SLOW_INT).setListener(null).start(); if (ViewCompat.getZ(mSearchToolbar) != 0f) { ViewCompat.animate(mSearchToolbar).z(0f).setDuration(600L).setInterpolator(LINEAR_OUT_SLOW_INT).start(); } // fade out the mScrim ViewCompat.animate(mScrim).alpha(0f).setDuration(400L).setInterpolator(LINEAR_OUT_SLOW_INT) .setListener(null).start(); }