Skip to content

AnimatedView

ZieIony edited this page May 19, 2015 · 2 revisions
public interface AnimatedView {
    public Animator getAnimator();

    public AnimUtils.Style getOutAnimation();

    public void setOutAnimation(AnimUtils.Style outAnim);

    public AnimUtils.Style getInAnimation();

    public void setInAnimation(AnimUtils.Style inAnim);
}

Implementation

    private AnimUtils.Style inAnim, outAnim;
    private Animator animator;

    public void setVisibility(final int visibility) {
        if (getVisibility() != View.VISIBLE && visibility == View.VISIBLE && inAnim != null) {
            animator = AnimUtils.animateIn(this, inAnim, null);
            super.setVisibility(visibility);
        } else if (getVisibility() == View.VISIBLE && visibility != View.VISIBLE) {
            animator = AnimUtils.animateOut(this, outAnim, new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    Button.super.setVisibility(visibility);
                }
            });
        }
    }

    public Animator getAnimator() {
        return animator;
    }

    public AnimUtils.Style getOutAnimation() {
        return outAnim;
    }

    public void setOutAnimation(AnimUtils.Style outAnim) {
        this.outAnim = outAnim;
    }

    public AnimUtils.Style getInAnimation() {
        return inAnim;
    }

    public void setInAnimation(AnimUtils.Style inAnim) {
        this.inAnim = inAnim;
    }
Clone this wiki locally