Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi;
import android.os.Build;
import android.view.View;
import android.view.ViewAnimationUtils;

public class Main {
    public static final int START_LEFT_TOP = 1;
    public static final int START_LEFT_BOTTOM = 2;
    public static final int START_RIGHT_TOP = 3;
    public static final int START_RIGHT_BOTTOM = 4;
    public static final int START_CENTER = 5;

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    private static void hide(final View view, int cornerType, int animRes, final boolean goneOrInvisible,
            final AnimatorListenerAdapter listener) {
        int[] amaya = calulateCorner(view, cornerType);
        //            if(view)
        Animator anim = ViewAnimationUtils.createCircularReveal(view, amaya[0], amaya[1], amaya[2], 0);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                view.setVisibility(goneOrInvisible ? View.GONE : View.INVISIBLE);
                if (listener != null)
                    listener.onAnimationEnd(animation);
            }
        });
        anim.setDuration(300);
        anim.start();
    }

    private static int[] calulateCorner(View view, int cornerType) {
        int x = (int) view.getX();
        int y = (int) view.getY();
        int w = view.getWidth();
        int h = view.getHeight();
        int[] amaya = new int[3];
        switch (cornerType) {
        default:
        case START_LEFT_TOP:
            amaya[0] = x;
            amaya[1] = y;
            break;
        case START_LEFT_BOTTOM:
            amaya[0] = x;
            amaya[1] = y + h;
            break;
        case START_RIGHT_TOP:
            amaya[0] = x + w;
            amaya[1] = y;
            break;
        case START_RIGHT_BOTTOM:
            amaya[0] = x + w;
            amaya[1] = y + h;
            break;
        case START_CENTER:
            amaya[0] = x + w / 2;
            amaya[1] = y + h / 2;
            break;
        }
        amaya[2] = (int) Math.sqrt(w * w + h * h);
        return amaya;
    }
}