Example usage for android.view ViewAnimationUtils createCircularReveal

List of usage examples for android.view ViewAnimationUtils createCircularReveal

Introduction

In this page you can find the example usage for android.view ViewAnimationUtils createCircularReveal.

Prototype

public static Animator createCircularReveal(View view, int centerX, int centerY, float startRadius,
        float endRadius) 

Source Link

Document

Returns an Animator which can animate a clipping circle.

Usage

From source file:Main.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Animator toCenterReveal(View view) {
    int width = view.getWidth();
    int height = view.getHeight();
    return ViewAnimationUtils.createCircularReveal(view, width / 2, height / 2, 0, Math.max(width, height));
}

From source file:Main.java

public static void revealColorFromCoordinates(int x, int y, View viewRoot) {
    float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());
    Animator anim = null;/*ww w. j av a  2 s  .  c om*/
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, 0, finalRadius);
    }
    //viewRoot.setBackgroundColor(ContextCompat.getColor(viewRoot.getContext(), R.color.colorPrimary));
    anim.setDuration(1000);
    anim.start();
}

From source file:Main.java

public static Animator createOutAnimator(View view) {
    // get the center for the clipping circle
    int cx = view.getWidth() / 2;
    int cy = view.getHeight() / 2;

    // get the initial radius for the clipping circle
    int initialRadius = view.getWidth();

    // create the animation (the final radius is zero)
    return ViewAnimationUtils.createCircularReveal(view, cx, cy, initialRadius, 0).setDuration(300);
}

From source file:Main.java

@TargetApi(21)
public static Animator circleReveal(View v, int centerX, int centerY, float startRadius, float endRadius,
        int duration) {
    Animator anim = ViewAnimationUtils.createCircularReveal(v, centerX, centerY, startRadius, endRadius);
    anim.setDuration(duration);//w  w  w.j av  a2s .  c o m
    anim.setInterpolator(mAccelerateInterpolator);
    anim.start();
    return anim;
}

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  a  2  s.co m*/
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            viewRoot.setVisibility(View.GONE);
        }
    });

    anim.start();
    return anim;
}

From source file:Main.java

public static void showRevealEffect(final View v, int centerX, int centerY,
        @Nullable Animator.AnimatorListener lis) {

    v.setVisibility(View.VISIBLE);

    int finalRadius = Math.max(v.getWidth(), v.getHeight());

    Animator anim = ViewAnimationUtils.createCircularReveal(v, centerX, centerY, 0, finalRadius);

    anim.setDuration(REVEAL_DURATION);/*from  ww  w.  j av  a2  s  .co  m*/

    if (lis != null)
        anim.addListener(lis);

    anim.start();
}

From source file:Main.java

public static Animator createInAnimator(View view) {
    // get the center for the clipping circle
    int cx = view.getWidth() / 2;
    int cy = view.getHeight() / 2;

    // get the final radius for the clipping circle
    int finalRadius = Math.max(view.getWidth(), view.getHeight());

    // create the animator for this view (the start radius is zero)
    return ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius).setDuration(300);
}

From source file:Main.java

@SuppressLint("NewApi")
public static void revealView(View toBeRevealed, View frame) {
    try {/*from w w w  .j  a v  a  2 s .c  om*/
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            // get the center for the clipping circle
            int cx = (frame.getLeft() + frame.getRight()) / 2;
            int cy = (frame.getTop() + frame.getBottom()) / 2;

            // get the final radius for the clipping circle
            int finalRadius = Math.max(frame.getWidth(), frame.getHeight());

            // create the animator for this view (the start radius is zero)
            Animator anim = ViewAnimationUtils.createCircularReveal(toBeRevealed, cx, cy, 0, finalRadius);

            // make the view visible and start the animation
            toBeRevealed.setVisibility(View.VISIBLE);
            anim.start();
        } else {
            toBeRevealed.setVisibility(View.VISIBLE);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

@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/*from   www .  j a  v  a 2s.c  o  m*/
        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();
}

From source file:Main.java

public static void enterReveal(final View view) {
    view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override/*from   w w w .j  av a2  s  . co m*/
        public void onGlobalLayout() {
            Animator animator = null;

            view.getViewTreeObserver().removeOnGlobalLayoutListener(this);

            int cx = view.getMeasuredWidth() / 2;
            int cy = view.getMeasuredHeight() / 2;

            try {
                final int finalRadius = Math.max(view.getWidth(), view.getHeight()) / 2 + 125;
                animator = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);

                animator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                    }
                });
            } catch (Exception ignored) {
            }

            view.setVisibility(View.VISIBLE);
            if (animator != null) {
                animator.start();
            }
        }
    });
}