List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter
AnimatorListenerAdapter
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateRemove(final ViewHolder holder) { endAnimation(holder);/* w w w . ja v a2 s . c om*/ final float prevAlpha = holder.itemView.getAlpha(); final Animator removeAnimator = ObjectAnimator.ofFloat(holder.itemView, View.ALPHA, 0f); removeAnimator.setDuration(getRemoveDuration()); removeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); holder.itemView.setAlpha(prevAlpha); dispatchRemoveFinished(holder); } }); mRemoveAnimatorsList.add(removeAnimator); mAnimators.put(holder, removeAnimator); return true; }
From source file:android.support.design.widget.FloatingActionButtonIcs.java
@Override void hide(@Nullable final FloatingActionButtonImpl.InternalVisibilityChangedListener listener, final boolean fromUser) { if (isOrWillBeHidden()) { // We either are or will soon be hidden, skip the call return;/*from w ww. j ava 2s . c o m*/ } mView.animate().cancel(); if (shouldAnimateVisibilityChange()) { mAnimState = ANIM_STATE_HIDING; mView.animate().scaleX(0f).scaleY(0f).alpha(0f).setDuration(SHOW_HIDE_ANIM_DURATION) .setInterpolator(AnimationUtils.FAST_OUT_LINEAR_IN_INTERPOLATOR) .setListener(new AnimatorListenerAdapter() { private boolean mCancelled; @Override public void onAnimationStart(Animator animation) { mView.internalSetVisibility(View.VISIBLE, fromUser); mCancelled = false; } @Override public void onAnimationCancel(Animator animation) { mCancelled = true; } @Override public void onAnimationEnd(Animator animation) { mAnimState = ANIM_STATE_NONE; if (!mCancelled) { mView.internalSetVisibility(fromUser ? View.GONE : View.INVISIBLE, fromUser); if (listener != null) { listener.onHidden(); } } } }); } else { // If the view isn't laid out, or we're in the editor, don't run the animation mView.internalSetVisibility(fromUser ? View.GONE : View.INVISIBLE, fromUser); if (listener != null) { listener.onHidden(); } } }
From source file:com.github.rubensousa.floatingtoolbar.FloatingAnimatorImpl.java
@Override public void show() { super.show(); int rootWidth = getRootView().getWidth(); float endFabX; if (getFab().getLeft() > rootWidth / 2f) { endFabX = getFab().getLeft() - getFab().getWidth(); } else {// w w w .j a v a 2s. c om endFabX = getFab().getLeft() + getFab().getWidth(); } PropertyValuesHolder xProperty = PropertyValuesHolder.ofFloat(View.X, endFabX); PropertyValuesHolder yProperty = PropertyValuesHolder.ofFloat(View.Y, getFloatingToolbar().getY() * 0.95f); PropertyValuesHolder scaleXProperty = PropertyValuesHolder.ofFloat(View.SCALE_X, 0); PropertyValuesHolder scaleYProperty = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(getFab(), xProperty, yProperty, scaleXProperty, scaleYProperty); animator.setDuration(FAB_MORPH_DURATION); animator.setInterpolator(new AccelerateInterpolator()); animator.start(); ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(getFloatingToolbar(), "scaleX", 1f); objectAnimator.setDuration(CIRCULAR_REVEAL_DURATION); objectAnimator.setStartDelay(CIRCULAR_REVEAL_DELAY); objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { getFloatingToolbar().setVisibility(View.VISIBLE); getFab().setVisibility(View.INVISIBLE); } }); objectAnimator.start(); }
From source file:by.gdgminsk.animationguide.util.AnimUtils.java
public static void scaleIn(final View view, int delay) { view.setAlpha(0.0f);//from ww w. j a v a 2 s.c o m view.setScaleX(0.0f); view.setScaleY(0.0f); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); ObjectAnimator scaleInAnimation = ObjectAnimator.ofPropertyValuesHolder(view, alpha, scaleX, scaleY); scaleInAnimation.setDuration(view.getResources().getInteger(R.integer.duration_fab_scale_in)); scaleInAnimation.setStartDelay(delay); scaleInAnimation.setInterpolator(EASE_IN_INTERPOLATOR); scaleInAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { view.setAlpha(1.0f); view.setScaleX(1.0f); view.setScaleY(1.0f); } }); scaleInAnimation.start(); }
From source file:com.sinyuk.jianyi.utils.list.SlideInItemAnimator.java
@Override public void runPendingAnimations() { super.runPendingAnimations(); if (!pendingAdds.isEmpty()) { for (int i = pendingAdds.size() - 1; i >= 0; i--) { final RecyclerView.ViewHolder holder = pendingAdds.get(i); holder.itemView.animate().alpha(1f).translationX(0f).translationY(0f).setDuration(getAddDuration()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { dispatchAddStarting(holder); }/*from ww w . j a v a 2s .c om*/ @Override public void onAnimationEnd(Animator animation) { animation.getListeners().remove(this); dispatchAddFinished(holder); dispatchFinishedWhenDone(); } @Override public void onAnimationCancel(Animator animation) { clearAnimatedValues(holder.itemView); } }).setInterpolator(new FastOutSlowInInterpolator()); pendingAdds.remove(i); } } }
From source file:com.andryr.guitartuner.Utils.java
public static void hide(final View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // get the center for the clipping circle int cx = view.getWidth() / 2; int cy = view.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(view, cx, cy, initialRadius, 0); // make the view invisible when the animation is done anim.addListener(new AnimatorListenerAdapter() { @Override//from w w w . ja v a2 s. com public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(View.INVISIBLE); } }); // start the animation anim.start(); } else { view.animate().alpha(0f).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(View.INVISIBLE); } }).start(); } }
From source file:com.destin.moeviewer.widget.SearchLayoutBehavior.java
void show(final View view) { view.animate().translationY(0).setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR).setDuration(200) .setListener(new AnimatorListenerAdapter() { @Override/*from w w w . j a v a 2 s . c o m*/ public void onAnimationStart(Animator animator) { view.setVisibility(View.VISIBLE); animating = true; } @Override public void onAnimationEnd(Animator animator) { animating = false; } @Override public void onAnimationCancel(Animator animator) { hide(view); } }); }
From source file:com.jaspervanriet.huntingthatproduct.Activities.WebActivity.java
private void goBack() { mBackPressed = true;// w w w .j a va2s.c o m mWebView.animate().translationY(Utils.getScreenHeight(this)).setDuration(200) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { WebActivity.super.onBackPressed(); overridePendingTransition(0, 0); finish(); } }).start(); }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateAdd(final ViewHolder holder) { endAnimation(holder);/*from w w w. j a v a 2 s . c o m*/ final float prevAlpha = holder.itemView.getAlpha(); holder.itemView.setAlpha(0f); final Animator addAnimator = ObjectAnimator.ofFloat(holder.itemView, View.ALPHA, 1f) .setDuration(getAddDuration()); addAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchAddStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); holder.itemView.setAlpha(prevAlpha); dispatchAddFinished(holder); } }); mAddAnimatorsList.add(addAnimator); mAnimators.put(holder, addAnimator); return true; }
From source file:com.chromium.fontinstaller.util.ViewUtils.java
public static void reveal(Activity activity, View view, View sourceView, int colorRes) { if (activity == null || view == null || sourceView == null) return;// w ww . j a va 2s .com if (isLollipop()) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView() .getOverlay(); final Rect displayRect = new Rect(); view.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(activity); revealView.setTop(displayRect.top); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes)); groupOverlay.add(revealView); final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); try { final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime)); alphaAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in)); view.setVisibility(View.VISIBLE); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); } }); animatorSet.start(); } catch (IllegalStateException e) { Timber.i("View is detached - not animating"); } } else { view.setVisibility(View.VISIBLE); } }