Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewAnimationUtils;

public class Main {
    public static void circularHide(final View view, Animator.AnimatorListener listener) {
        Animator anim = createCircularHideAnimator(view, listener);
        if (anim != null)
            anim.start();
    }

    public static Animator createCircularHideAnimator(final View view,
            @Nullable Animator.AnimatorListener listener) {
        if (view.getWindowToken() == null || view.getVisibility() == View.INVISIBLE)
            return null;

        // get the center for the clipping circle
        int cx = (view.getLeft() + view.getRight()) / 2;
        int cy = (view.getTop() + view.getBottom()) / 2;

        // 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);
            }
        });

        if (listener != null) {
            anim.addListener(listener);
        }
        return anim;
    }
}