Example usage for android.animation AnimatorListenerAdapter AnimatorListenerAdapter

List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter

Introduction

In this page you can find the example usage for android.animation AnimatorListenerAdapter AnimatorListenerAdapter.

Prototype

AnimatorListenerAdapter

Source Link

Usage

From source file:Main.java

public static void fadeOutView(final View view) {
    view.animate().alpha(0f).setListener(new AnimatorListenerAdapter() {

        public void onAnimationEnd(Animator animation) {
            view.setVisibility(View.INVISIBLE);
            view.setAlpha(1f);//from w  w  w . j a v  a 2s.com
            view.animate().setListener(null);
        }
    });
}

From source file:Main.java

public static void fadeOut(final View view, final AnimatorListenerAdapter listener) {
    view.animate().alpha(0).setListener(new AnimatorListenerAdapter() {
        @Override/*from   www .j  a  va 2  s.c  o m*/
        public void onAnimationEnd(Animator animation) {
            listener.onAnimationEnd(animation);
            view.setAlpha(1f);
        }
    });

}

From source file:Main.java

public static void fade_GONE(final View view, int duration) {
    view.animate().alpha(0.0f).setDuration(duration).setListener(new AnimatorListenerAdapter() {
        @Override/*w w w .jav a  2  s. c o m*/
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setVisibility(View.GONE);
        }
    });
}

From source file:Main.java

public static void fade_VISIBLE(final View view, int duration) {
    view.animate().alpha(100.0f).setDuration(duration).setListener(new AnimatorListenerAdapter() {
        @Override//  ww  w .java2  s.co m
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            view.setVisibility(View.VISIBLE);
        }
    });
}

From source file:Main.java

/**
 * Fade in or fade out a given view.//w  ww . j a  v a 2  s.  c o  m
 */
public static void animateViewSetVisible(final boolean visible, final View view) {
    view.setVisibility(View.VISIBLE);
    view.setAlpha(visible ? 0 : 1);
    view.animate().setDuration(300).alpha(visible ? 1 : 0).setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            view.setVisibility(visible ? View.VISIBLE : View.GONE);
        }
    });
}

From source file:Main.java

public static void fadeViewOut(final View view, final int duration) {
    if (view.getVisibility() == View.GONE)
        return;//  w  ww. j  av  a 2 s .  c  o  m
    if (Build.VERSION.SDK_INT >= 12) {
        view.animate().setDuration(duration).alpha(0f).setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                view.setVisibility(View.GONE);
            }
        });
    } else {
        view.setVisibility(View.GONE);
    }
}

From source file:Main.java

public static ObjectAnimator fadeIn(final View v) {
    ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(v, "alpha", 0f, 1f);
    alphaAnim.setDuration(ANIM_DURATION_FADEIN);
    alphaAnim.addListener(new AnimatorListenerAdapter() {
        @Override// w  ww  . j av  a  2s.com
        public void onAnimationStart(Animator animation) {
            v.setVisibility(View.VISIBLE);
        }
    });

    return alphaAnim;
}

From source file:Main.java

public static void animHide(final View v, int duration, float from, float to, final boolean gone) {
    v.clearAnimation();/*  w w  w  .  jav  a  2s .c om*/
    ObjectAnimator anim = ObjectAnimator.ofFloat(v, "alpha", from, to).setDuration(duration);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (gone) {
                v.setVisibility(View.GONE);
            }
        }
    });
    anim.start();
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static Animator createHideAnim(final View viewRoot, int x, int y) {

    float initialRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());

    Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, initialRadius, 0);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override//  w  w w .j a v a2 s . c om
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            viewRoot.setVisibility(View.GONE);
        }
    });

    anim.start();
    return anim;
}

From source file:Main.java

public static ObjectAnimator inflate(final View v) {
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0f, 1f);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0f, 1f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(v, scaleX, scaleY);
    animator.setDuration(ANIM_DURATION_INFLATE);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override/*from ww w. j  a va  2s  .co m*/
        public void onAnimationStart(Animator animation) {
            v.setVisibility(View.VISIBLE);
        }
    });

    return animator;
}