List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter
AnimatorListenerAdapter
From source file:Main.java
public static void hideRevealEffect(final View v, int centerX, int centerY, int initialRadius) { v.setVisibility(View.VISIBLE); // create the animation (the final radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(v, centerX, centerY, initialRadius, 0); anim.setDuration(350);//from w ww. j av a 2 s.c o m // make the view invisible when the animation is done anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); v.setVisibility(View.INVISIBLE); } }); anim.start(); }
From source file:Main.java
/** * Animate a transition between two views * * @param viewToFadeOut/*from ww w .ja v a 2s.co m*/ * @param viewToFadeIn * @param viewToFadeOutVisibilityState */ public static void crossFade(final View viewToFadeOut, final View viewToFadeIn, final int viewToFadeOutVisibilityState) { viewToFadeIn.setAlpha(0f); viewToFadeIn.setVisibility(View.VISIBLE); viewToFadeIn.animate().alpha(1f).setDuration(SHORT_ANIMATION_DURATION).setListener(null); viewToFadeOut.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { viewToFadeOut.setVisibility(viewToFadeOutVisibilityState); } }); }
From source file:Main.java
/** Fade out the given view. */ public static void fadeOut(final View view, float opacity, int duration) { // Animate the loading view to the given opacity. AnimatorListenerAdapter animatorListenerAdapter = null; if (opacity == 0f) { // After the animation ends, set its visibility to GONE as an optimization step // (it won't participate in layout passes, etc.) animatorListenerAdapter = new AnimatorListenerAdapter() { @Override/*from w w w . ja v a2s. c o m*/ public void onAnimationEnd(Animator animation) { view.setVisibility(View.GONE); } }; } view.animate().withLayer().alpha(opacity).setDuration(duration).setListener(animatorListenerAdapter); }
From source file:com.microsoft.azure.engagement.ProductDiscountActivity.java
/** * Method that animates a view/*from w w w . j ava 2 s.c o m*/ * * @param view The view to animate * @param objectAnimator The objectAnimator to play * @param isVisible The visibility of the view at the end of the animation */ public static final void performAnimation(final View view, ObjectAnimator objectAnimator, final boolean isVisible) { view.setVisibility(View.VISIBLE); objectAnimator.setDuration(300); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(objectAnimator); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setVisibility(isVisible ? View.VISIBLE : View.INVISIBLE); } }); animatorSet.start(); }
From source file:Main.java
public static void animatePhotoLike(final ImageView likeBg, final ImageView likeIcon) { likeBg.setVisibility(View.VISIBLE); likeIcon.setVisibility(View.VISIBLE); likeBg.setScaleY(0.1f);/*from w w w .j a v a 2 s . co m*/ likeBg.setScaleX(0.1f); likeBg.setAlpha(1f); likeIcon.setScaleY(0.1f); likeIcon.setScaleX(0.1f); AnimatorSet animatorSet = new AnimatorSet(); ObjectAnimator bgScaleYAnim = ObjectAnimator.ofFloat(likeBg, "scaleY", 0.1f, 1f); bgScaleYAnim.setDuration(200); bgScaleYAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator bgScaleXAnim = ObjectAnimator.ofFloat(likeBg, "scaleX", 0.1f, 1f); bgScaleXAnim.setDuration(200); bgScaleXAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator bgAlphaAnim = ObjectAnimator.ofFloat(likeBg, "alpha", 1f, 0f); bgAlphaAnim.setDuration(200); bgAlphaAnim.setStartDelay(150); bgAlphaAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(likeIcon, "scaleY", 0.1f, 1f); imgScaleUpYAnim.setDuration(300); imgScaleUpYAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(likeIcon, "scaleX", 0.1f, 1f); imgScaleUpXAnim.setDuration(300); imgScaleUpXAnim.setInterpolator(DECCELERATE_INTERPOLATOR); ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(likeIcon, "scaleY", 1f, 0f); imgScaleDownYAnim.setDuration(300); imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR); ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(likeIcon, "scaleX", 1f, 0f); imgScaleDownXAnim.setDuration(300); imgScaleDownXAnim.setInterpolator(ACCELERATE_INTERPOLATOR); animatorSet.playTogether(bgScaleYAnim, bgScaleXAnim, bgAlphaAnim, imgScaleUpYAnim, imgScaleUpXAnim); animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpYAnim); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { resetLikeAnimationState(likeBg, likeIcon); } }); animatorSet.start(); }
From source file:com.kogitune.prelollipoptransition.fragment.SubFragment.java
@Nullable @Override// ww w. j a v a2 s .c om public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_sub, container, false); final ExitFragmentTransition exitFragmentTransition = FragmentTransition.with(this) .interpolator(new LinearOutSlowInInterpolator()).to(v.findViewById(R.id.sub_imageView)) .start(savedInstanceState); exitFragmentTransition.exitListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { Log.d("TAG", "onAnimationStart: "); } @Override public void onAnimationEnd(Animator animation) { Log.d("TAG", "onAnimationEnd: "); } }).interpolator(new FastOutSlowInInterpolator()); exitFragmentTransition.startExitListening(); return v; }
From source file:com.kogitune.prelollipoptransition.fragment.EndFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_end, container, false); final ExitFragmentTransition exitFragmentTransition = FragmentTransition.with(this) .interpolator(new LinearOutSlowInInterpolator()).to(v.findViewById(R.id.fragment_imageView)) .start(savedInstanceState);/*from w w w. j ava2s. co m*/ exitFragmentTransition.exitListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { Log.d("TAG", "onAnimationStart: "); } @Override public void onAnimationEnd(Animator animation) { Log.d("TAG", "onAnimationEnd: "); } }).interpolator(new FastOutSlowInInterpolator()); exitFragmentTransition.startExitListening(); return v; }
From source file:com.mvcoding.financius.feature.RevealTransition.java
@Override public Animator onAppear(ViewGroup sceneRoot, final View view, TransitionValues startValues, TransitionValues endValues) {//from ww w. j av a 2 s . c o m float radius = calculateMaxRadius(view); final float originalAlpha = 1; // TODO: For some reason this returns 0 view.getAlpha(); view.setAlpha(0f); Animator reveal = createAnimator(view, 0, radius); reveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { view.setAlpha(originalAlpha); } }); return reveal; }
From source file:com.destin.moeviewer.widget.SearchLayoutBehavior.java
void hide(final View view) { view.animate().translationY(-view.getHeight()).setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR) .setDuration(200).setListener(new AnimatorListenerAdapter() { @Override//from w w w .ja v a 2 s . c o m public void onAnimationStart(Animator animator) { animating = true; } @Override public void onAnimationEnd(Animator animator) { view.setVisibility(View.GONE); animating = false; } @Override public void onAnimationCancel(Animator animator) { show(view); } }); }
From source file:android.support.designox.widget.FloatingActionButtonIcs.java
@Override void hide(@Nullable final InternalVisibilityChangedListener listener, final boolean fromUser) { if (mIsHiding || mView.getVisibility() != View.VISIBLE) { // A hide animation is in progress, or we're already hidden. Skip the call if (listener != null) { listener.onHidden();/*from ww w .j av a2 s . co m*/ } return; } if (!ViewCompat.isLaidOut(mView) || mView.isInEditMode()) { // If the view isn't laid out, or we're in the editor, don't run the animation mView.internalSetVisibility(View.GONE, fromUser); if (listener != null) { listener.onHidden(); } } else { mView.animate().cancel(); 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) { mIsHiding = true; mCancelled = false; mView.internalSetVisibility(View.VISIBLE, fromUser); } @Override public void onAnimationCancel(Animator animation) { mIsHiding = false; mCancelled = true; } @Override public void onAnimationEnd(Animator animation) { mIsHiding = false; if (!mCancelled) { mView.internalSetVisibility(View.GONE, fromUser); if (listener != null) { listener.onHidden(); } } } }); } }