List of usage examples for android.animation Animator addListener
public void addListener(AnimatorListener listener)
From source file:com.google.samples.apps.iosched.util.LPreviewUtilsBase.java
public void setOrAnimatePlusCheckIcon(final ImageView imageView, boolean isCheck, boolean allowAnimate) { final int imageResId = isCheck ? R.drawable.add_schedule_button_icon_checked : R.drawable.add_schedule_button_icon_unchecked; if (imageView.getTag() != null) { if (imageView.getTag() instanceof Animator) { Animator anim = (Animator) imageView.getTag(); anim.end();/*from w w w .ja v a 2 s. c o m*/ imageView.setAlpha(1f); } } if (allowAnimate && isCheck) { int duration = mActivity.getResources().getInteger(android.R.integer.config_shortAnimTime); Animator outAnimator = ObjectAnimator.ofFloat(imageView, View.ALPHA, 0f); outAnimator.setDuration(duration / 2); outAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setImageResource(imageResId); } }); AnimatorSet inAnimator = new AnimatorSet(); outAnimator.setDuration(duration); inAnimator.playTogether(ObjectAnimator.ofFloat(imageView, View.ALPHA, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_X, 0f, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 0f, 1f)); AnimatorSet set = new AnimatorSet(); set.playSequentially(outAnimator, inAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setTag(null); } }); imageView.setTag(set); set.start(); } else { mHandler.post(new Runnable() { @Override public void run() { imageView.setImageResource(imageResId); } }); } }
From source file:fr.paug.droidcon.util.LPreviewUtilsBase.java
public void setOrAnimatePlusCheckIcon(final ImageView imageView, boolean isCheck, boolean allowAnimate, int resIdChecked) { final int imageResId = isCheck ? resIdChecked : R.drawable.add_schedule_button_icon_unchecked; if (imageView.getTag() != null) { if (imageView.getTag() instanceof Animator) { Animator anim = (Animator) imageView.getTag(); anim.end();/*w w w.j a va 2 s . com*/ imageView.setAlpha(1f); } } if (allowAnimate && isCheck) { int duration = mActivity.getResources().getInteger(android.R.integer.config_shortAnimTime); Animator outAnimator = ObjectAnimator.ofFloat(imageView, View.ALPHA, 0f); outAnimator.setDuration(duration / 2); outAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setImageResource(imageResId); } }); AnimatorSet inAnimator = new AnimatorSet(); outAnimator.setDuration(duration); inAnimator.playTogether(ObjectAnimator.ofFloat(imageView, View.ALPHA, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_X, 0f, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 0f, 1f)); AnimatorSet set = new AnimatorSet(); set.playSequentially(outAnimator, inAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setTag(null); } }); imageView.setTag(set); set.start(); } else { mHandler.post(new Runnable() { @Override public void run() { imageView.setImageResource(imageResId); } }); } }
From source file:com.truizlop.fabreveallayout.FABRevealLayout.java
private void expandCircle() { Animator expandAnimator = circularExpandingView.expand(); ;/*from ww w .j a v a 2 s . c o m*/ expandAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); swapViews(); } }); expandAnimator.start(); }
From source file:com.sysdata.widget.accordion.CollapsedViewHolder.java
@Override public Animator onAnimateChange(final ViewHolder oldHolder, ViewHolder newHolder, long duration) { if (!(oldHolder instanceof ArrowItemViewHolder) || !(newHolder instanceof ArrowItemViewHolder)) { return null; }//from w ww. ja v a 2 s . c o m final boolean isCollapsing = this == newHolder; setChangingViewsAlpha(isCollapsing ? 0f : 1f); final Animator changeAnimatorSet = isCollapsing ? createCollapsingAnimator((ArrowItemViewHolder) oldHolder, duration) : createExpandingAnimator((ArrowItemViewHolder) newHolder, duration); changeAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { if (arrow != null) { arrow.setVisibility(View.VISIBLE); arrow.setTranslationY(0f); arrow.jumpDrawablesToCurrentState(); } setChangingViewsAlpha(1f); } }); return changeAnimatorSet; }
From source file:com.google.samples.apps.ourstreets.fragment.GalleryFragment.java
@NonNull private Animator createCircularReveal(@NonNull View targetView) { Animator circularReveal = ViewUtils.createCircularReveal(targetView, R.id.progress, INTERPOLATOR); circularReveal.addListener(new AnimatorListenerAdapter() { @Override/* w ww.j ava 2 s. c o m*/ public void onAnimationStart(Animator animation) { swapEmptyWithContentView(true); } }); return circularReveal; }
From source file:org.ciasaboark.tacere.activity.AboutActivity.java
@TargetApi(21) private void toggleVisibilityCircularReveal(final View view) { if (view.getVisibility() == View.VISIBLE) { //the view is visible, so animate it out then set visibility to GONE int cx;//from w ww . j ava 2 s . com int cy; if (this.x == null || this.y == null) { // get the center for the clipping circle cx = (view.getLeft() + view.getRight()) / 2; cy = (view.getTop() + view.getBottom()) / 2; } else { //a touch event has been recorded, use the last known coordinates cx = this.x; cy = this.y; } // get the initial radius for the clipping circle int initialRadius = view.getWidth(); // create the animation (the final radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(View.INVISIBLE); } }); anim.setDuration(700); // start the animation anim.start(); } else { //the view is not visible (either GONE or INVISIBILE), set visibility to VISIBLE, then //animate in int cx; int cy; if (this.x == null || this.y == null) { // get the center for the clipping circle cx = (view.getLeft() + view.getRight()) / 2; cy = (view.getTop() + view.getBottom()) / 2; } else { //a touch event has been recorded, use the last known coordinates cx = this.x; cy = this.y; } // get the final radius for the clipping circle int finalRadius = view.getWidth(); // create and start the animator for this view // (the start radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius); anim.setDuration(500); view.setVisibility(View.VISIBLE); anim.start(); } }
From source file:com.sysdata.widget.accordion.ExpandedViewHolder.java
@Override public Animator onAnimateChange(final ViewHolder oldHolder, ViewHolder newHolder, long duration) { if (!(oldHolder instanceof ArrowItemViewHolder) || !(newHolder instanceof ArrowItemViewHolder)) { return null; }/* w ww. ja va2 s. c o m*/ final boolean isExpanding = this == newHolder; AnimatorUtils.setBackgroundAlpha(itemView, isExpanding ? 0 : 255); setChangingViewsAlpha(isExpanding ? 0f : 1f); final Animator changeAnimatorSet = isExpanding ? createExpandingAnimator((ArrowItemViewHolder) oldHolder, duration) : createCollapsingAnimator((ArrowItemViewHolder) newHolder, duration); changeAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { AnimatorUtils.setBackgroundAlpha(itemView, 255); if (arrow != null) { arrow.setVisibility(View.VISIBLE); arrow.setTranslationY(0f); arrow.jumpDrawablesToCurrentState(); } setChangingViewsAlpha(1f); } }); return changeAnimatorSet; }
From source file:me.sweetll.tucao.widget.PasswordEntry.java
private void passwordVisibilityToggled(boolean isMasked, CharSequence password) { if (maskDrawable == null) { // lazily create the drawable that morphs the dots if (!ViewCompat.isLaidOut(this) || getText().length() < 1) return; maskDrawable = new MaskMorphDrawable(getContext(), getPaint(), getBaseline(), getLayout().getPrimaryHorizontal(1), getTextLeft()); maskDrawable.setBounds(getPaddingLeft(), getPaddingTop(), getPaddingLeft(), getHeight() - getPaddingBottom()); getOverlay().add(maskDrawable);/*from w ww. j av a2s . c o m*/ } // hide the text during the animation setTextColor(Color.TRANSPARENT); Animator maskMorph = isMasked ? maskDrawable.createShowMaskAnimator(password) : maskDrawable.createHideMaskAnimator(password); maskMorph.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setTextColor(textColor); // restore the proper text color } }); maskMorph.start(); }
From source file:org.chromium.chrome.browser.physicalweb.ListUrlsActivity.java
private void hideBottomBar() { Animator animator = createTranslationYAnimator(mBottomBar, mBottomBar.getHeight(), DURATION_SLIDE_DOWN_MS); animator.addListener(new AnimatorListenerAdapter() { @Override//w w w . jav a 2 s . com public void onAnimationEnd(Animator animation) { mBottomBar.setVisibility(View.GONE); } }); animator.start(); }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateAdd(final ViewHolder holder) { endAnimation(holder);/* www . j av 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; }