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:com.google.android.apps.santatracker.launch.TvStartupActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void playCircularRevealTransition(View srcView) {

    showColorMask(true);//from   w ww. j  a  v a 2s .  c  om
    View mask = findViewById(R.id.content_mask);
    srcView.getGlobalVisibleRect(mSrcRect);
    Animator anim = ViewAnimationUtils.createCircularReveal(mask, mSrcRect.centerX(), mSrcRect.centerY(), 0.f,
            mask.getWidth());
    anim.start();
}

From source file:org.numixproject.hermes.activity.ConversationActivity.java

private void hideConversationLayout() {
    // previously visible view

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

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

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        // create the animation (the final radius is zero)
        Animator anim = ViewAnimationUtils.createCircularReveal(conversationLayout, cx, cy, initialRadius, 0);
        anim.setInterpolator(new AccelerateDecelerateInterpolator());

        // make the view invisible when the animation is done
        anim.addListener(new AnimatorListenerAdapter() {
            @Override//from w  w  w. j  av a 2  s.c o m
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                conversationLayout.setVisibility(View.INVISIBLE);
            }
        });

        // start the animation
        anim.start();
    } else {
        conversationLayout.setAlpha(1.f);
        conversationLayout.setScaleX(1.f);
        conversationLayout.setScaleY(1.f);
        conversationLayout.animate().alpha(0.f).scaleX(0.f).scaleY(0.f).setDuration(300)
                .setInterpolator(new AccelerateDecelerateInterpolator()).start();
    }
    conversationLayout.setVisibility(View.INVISIBLE);
}

From source file:com.igniva.filemanager.activities.MainActivity.java

/**
 * show search view with a circular reveal animation
 *///from   w  w w.j  a v  a 2s. co m
void revealSearchView() {

    final int START_RADIUS = 16;
    int endRadius = Math.max(toolbar.getWidth(), toolbar.getHeight());

    Animator animator;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32,
                searchCoords[1] - 16, START_RADIUS, endRadius);
    } else {
        // TODO:ViewAnimationUtils.createCircularReveal
        animator = new ObjectAnimator().ofFloat(searchViewLayout, "alpha", 0f, 1f);
    }

    utils.revealShow(mFabBackground, true);

    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(600);
    searchViewLayout.setVisibility(View.VISIBLE);
    animator.start();
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {

            searchViewEditText.requestFocus();
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(searchViewEditText, InputMethodManager.SHOW_IMPLICIT);
            isSearchViewEnabled = true;
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });

}

From source file:com.igniva.filemanager.activities.MainActivity.java

/**
 * hide search view with a circular reveal animation
 *//*from   ww  w  .  j a v  a2  s. c o m*/
public void hideSearchView() {

    final int END_RADIUS = 16;
    int startRadius = Math.max(searchViewLayout.getWidth(), searchViewLayout.getHeight());
    Animator animator;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32,
                searchCoords[1] - 16, startRadius, END_RADIUS);
    } else {
        // TODO: ViewAnimationUtils.createCircularReveal
        animator = new ObjectAnimator().ofFloat(searchViewLayout, "alpha", 1f, 0f);
    }

    // removing background fade view
    utils.revealShow(mFabBackground, false);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(600);
    animator.start();
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {

            searchViewLayout.setVisibility(View.GONE);
            isSearchViewEnabled = false;
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            inputMethodManager.hideSoftInputFromWindow(searchViewEditText.getWindowToken(),
                    InputMethodManager.HIDE_IMPLICIT_ONLY);
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
}

From source file:com.rks.musicx.misc.utils.Helper.java

@NonNull
public static Animator getCircularShowAnimtion(@NonNull View view) {
    int cx = view.getWidth() / 2;
    int cy = view.getHeight() / 2;
    int finalRadius = (int) Math.hypot(view.getWidth(), view.getHeight());
    Animator animation = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
    animation.setDuration(500);//from   w  w  w  .j  a  va2  s  .  co  m
    return animation;
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

/**
 * show search view with a circular reveal animation
 *///from  w  w  w . j a  v  a2s.  co m
void revealSearchView() {
    final int START_RADIUS = 16;
    int endRadius = Math.max(toolbar.getWidth(), toolbar.getHeight());

    Animator animator;
    if (SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32,
                searchCoords[1] - 16, START_RADIUS, endRadius);
    } else {
        // TODO:ViewAnimationUtils.createCircularReveal
        animator = ObjectAnimator.ofFloat(searchViewLayout, "alpha", 0f, 1f);
    }

    utils.revealShow(fabBgView, true);

    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(600);
    searchViewLayout.setVisibility(View.VISIBLE);
    animator.start();
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            searchViewEditText.requestFocus();
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(searchViewEditText, InputMethodManager.SHOW_IMPLICIT);
            isSearchViewEnabled = true;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
}

From source file:com.rks.musicx.misc.utils.Helper.java

@NonNull
public static Animator getCircularHideAnimtion(@NonNull View view) {
    int cx = view.getWidth() / 2;
    int cy = view.getHeight() / 2;
    int finalRadius = (int) Math.hypot(view.getWidth(), view.getHeight());
    Animator animation = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
    animation.setDuration(500);/*from  w ww  .  j  a va2 s.  c o m*/
    return animation;
}

From source file:com.amaze.carbonfilemanager.activities.MainActivity.java

/**
 * hide search view with a circular reveal animation
 */// w  w  w  .  j  a  v  a2s .  co m
public void hideSearchView() {
    final int END_RADIUS = 16;
    int startRadius = Math.max(searchViewLayout.getWidth(), searchViewLayout.getHeight());
    Animator animator;
    if (SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        animator = ViewAnimationUtils.createCircularReveal(searchViewLayout, searchCoords[0] + 32,
                searchCoords[1] - 16, startRadius, END_RADIUS);
    } else {
        // TODO: ViewAnimationUtils.createCircularReveal
        animator = ObjectAnimator.ofFloat(searchViewLayout, "alpha", 1f, 0f);
    }

    // removing background fade view
    utils.revealShow(fabBgView, false);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(600);
    animator.start();
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            searchViewLayout.setVisibility(View.GONE);
            isSearchViewEnabled = false;
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            inputMethodManager.hideSoftInputFromWindow(searchViewEditText.getWindowToken(),
                    InputMethodManager.HIDE_IMPLICIT_ONLY);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
}

From source file:com.zertinteractive.wallpaper.MainActivity.java

@SuppressWarnings("NewApi")
private void animateRevealHide(final View viewRoot) {
    int cx = (viewRoot.getLeft() + viewRoot.getRight()) / 2;
    int cy = (viewRoot.getTop() + viewRoot.getBottom()) / 2;
    int initialRadius = viewRoot.getWidth();

    android.animation.Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, cx, cy, initialRadius,
            0);//from   w w  w  . ja v  a  2  s  .c  om
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(android.animation.Animator animation) {
            super.onAnimationEnd(animation);
            viewRoot.setVisibility(View.INVISIBLE);
        }
    });
    anim.setDuration(getResources().getInteger(R.integer.anim_duration_medium));
    anim.start();
}

From source file:com.zertinteractive.wallpaper.MainActivity.java

@SuppressWarnings("NewApi")
private android.animation.Animator animateRevealColorFromCoordinates(ViewGroup viewRoot, @ColorRes int color,
        int x, int y) {
    float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());

    android.animation.Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, x, y, 0, finalRadius);
    viewRoot.setBackgroundColor(ContextCompat.getColor(this, color));
    anim.setDuration(getResources().getInteger(R.integer.anim_duration_long));
    anim.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.start();/*from   w ww . j  a va 2  s.  c  om*/
    return anim;
}