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:br.liveo.searchliveo.SearchCardLiveo.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void showAnimation() {
    try {/*  w  w w  .ja  v  a  2 s.c  om*/

        if (getStatusBarShowColor() != -1) {
            mContext.getWindow().setStatusBarColor(getStatusBarShowColor());
        } else {
            mContext.getWindow()
                    .setStatusBarColor(ContextCompat.getColor(mContext, R.color.search_liveo_primary_dark));
        }

        final Animator animator = ViewAnimationUtils.createCircularReveal(mCardSearch,
                mCardSearch.getWidth() - (int) dpToPixel(24, this.mContext), (int) dpToPixel(23, this.mContext),
                0, (float) Math.hypot(mCardSearch.getWidth(), mCardSearch.getHeight()));
        animator.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mContext.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                                .toggleSoftInput(InputMethodManager.SHOW_FORCED,
                                        InputMethodManager.HIDE_IMPLICIT_ONLY);
                    }
                });
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });

        animator.setDuration(300);
        animator.start();
    } catch (Exception e) {
        e.getStackTrace();
        mContext.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                        .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
            }
        });
    }

    mCardSearch.setVisibility(View.VISIBLE);
}

From source file:br.liveo.searchliveo.SearchLiveo.java

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

        if (getStatusBarHideColor() != -1) {
            mContext.getWindow().setStatusBarColor(getStatusBarHideColor());
        } else {//from ww w  . jav a 2s  .  com
            mContext.getWindow().setStatusBarColor(getColorPrimaryDark());
        }

        final Animator animatorHide = ViewAnimationUtils.createCircularReveal(mViewSearch,
                mViewSearch.getWidth() - (int) dpToPixel(24, mContext), (int) dpToPixel(23, mContext),
                (float) Math.hypot(mViewSearch.getWidth(), mViewSearch.getHeight()), 0);
        animatorHide.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

                mContext.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                                .hideSoftInputFromWindow(mRecyclerView.getWindowToken(), 0);
                    }
                });
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mViewSearch.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
        animatorHide.setDuration(200);
        animatorHide.start();

    } else {

        mContext.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                        .hideSoftInputFromWindow(mRecyclerView.getWindowToken(), 0);
            }
        });

        Animation mFadeOut = AnimationUtils.loadAnimation(mContext.getApplicationContext(),
                android.R.anim.fade_out);
        mViewSearch.setAnimation(mFadeOut);
        mViewSearch.setVisibility(View.INVISIBLE);
    }

    mEdtSearch.setText("");
    mViewSearch.setEnabled(false);
    return this;
}

From source file:br.liveo.searchliveo.SearchCardLiveo.java

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

        if (getStatusBarHideColor() != -1) {
            mContext.getWindow().setStatusBarColor(getStatusBarHideColor());
        } else {/*from w  w  w  .  j  a  v  a2 s  .  com*/
            mContext.getWindow().setStatusBarColor(getColorPrimaryDark());
        }

        final Animator animatorHide = ViewAnimationUtils.createCircularReveal(mCardSearch,
                mCardSearch.getWidth() - (int) dpToPixel(24, mContext), (int) dpToPixel(23, mContext),
                (float) Math.hypot(mCardSearch.getWidth(), mCardSearch.getHeight()), 0);
        animatorHide.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

                mContext.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                                .hideSoftInputFromWindow(mRecyclerView.getWindowToken(), 0);
                    }
                });
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mCardSearch.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
        animatorHide.setDuration(200);
        animatorHide.start();

    } else {

        mContext.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ((InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE))
                        .hideSoftInputFromWindow(mRecyclerView.getWindowToken(), 0);
            }
        });

        Animation mFadeOut = AnimationUtils.loadAnimation(mContext.getApplicationContext(),
                android.R.anim.fade_out);
        mCardSearch.setAnimation(mFadeOut);
        mCardSearch.setVisibility(View.INVISIBLE);
    }

    mEdtSearch.setText("");
    mCardSearch.setEnabled(false);
    return this;
}

From source file:io.plaidapp.ui.HomeActivity.java

void revealPostingProgress() {
    Animator reveal = ViewAnimationUtils.createCircularReveal(fabPosting, (int) fabPosting.getPivotX(),
            (int) fabPosting.getPivotY(), 0f, fabPosting.getWidth() / 2).setDuration(600L);
    reveal.setInterpolator(AnimUtils.getFastOutLinearInInterpolator(this));
    reveal.start();//from w  ww  . j a  v  a 2 s . co  m
    AnimatedVectorDrawable uploading = (AnimatedVectorDrawable) getDrawable(R.drawable.avd_uploading);
    if (uploading != null) {
        fabPosting.setImageDrawable(uploading);
        uploading.start();
    }
}

From source file:com.fastbootmobile.encore.utils.Utils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Animator animateCircleReveal(final View view, final int cx, final int cy, final int startRadius,
        final int endRadius, final long duration, final long startDelay) {
    Animator animator = ViewAnimationUtils.createCircularReveal(view, cx, cy, startRadius, endRadius)
            .setDuration(duration);/*from  w w  w .ja  v a 2  s .c o  m*/
    animator.setStartDelay(startDelay);
    animator.setInterpolator(new DecelerateInterpolator());
    animator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
            view.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (startRadius > endRadius) {
                view.setVisibility(View.INVISIBLE);
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    animator.start();

    return animator;
}

From source file:com.android.calculator2.Calculator.java

private void reveal(View sourceView, int colorRes, AnimatorListener listener) {
    final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    mDisplayView.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(this);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(getResources().getColor(colorRes));
    groupOverlay.add(revealView);//w  ww.  ja va2s.c om

    final int[] clearLocation = new int[2];
    sourceView.getLocationInWindow(clearLocation);
    clearLocation[0] += sourceView.getWidth() / 2;
    clearLocation[1] += sourceView.getHeight() / 2;

    final int revealCenterX = clearLocation[0] - revealView.getLeft();
    final int revealCenterY = clearLocation[1] - revealView.getTop();

    final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
    final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
    final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
    final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

    final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX,
            revealCenterY, 0.0f, revealRadius);
    revealAnimator.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime));
    revealAnimator.addListener(listener);

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime));

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(revealAnimator).before(alphaAnimator);
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            groupOverlay.remove(revealView);
            mCurrentAnimator = null;
        }
    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}

From source file:com.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

void enterReveal(View view) {
    // previously invisible view
    final View myView = view;

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

    // create the animator for this view (the start radius is zero)
    Animator anim = ViewAnimationUtils.createCircularReveal(myView, x, y, 0, finalRadius).setDuration(600);

    // make the view visible and start the animation
    myView.setVisibility(View.VISIBLE);
    anim.start();/*from  www . j  av  a 2  s  .  c o m*/
}

From source file:bottombar.BottomBar.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void backgroundCircularRevealAnimation(View clickedView, final int newColor) {
    int centerX = (int) (ViewCompat.getX(clickedView) + (clickedView.getMeasuredWidth() / 2));
    int yOffset = isTabletMode ? (int) ViewCompat.getY(clickedView) : 0;
    int centerY = yOffset + clickedView.getMeasuredHeight() / 2;
    int startRadius = 0;
    int finalRadius = isTabletMode ? outerContainer.getHeight() : outerContainer.getWidth();

    Animator animator = ViewAnimationUtils.createCircularReveal(backgroundOverlay, centerX, centerY,
            startRadius, finalRadius);//from w w w  .  j  ava  2s  .  co m

    if (isTabletMode) {
        animator.setDuration(500);
    }

    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            onEnd();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            onEnd();
        }

        private void onEnd() {
            outerContainer.setBackgroundColor(newColor);
            backgroundOverlay.setVisibility(View.INVISIBLE);
            ViewCompat.setAlpha(backgroundOverlay, 1);
        }
    });

    animator.start();
}

From source file:com.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

void exitReveal(View view) {
    // previously visible view
    final View myView = view;

    // get the initial radius for the clipping circle
    int initialRadius = Math.max(myView.getWidth(), myView.getHeight());

    // create the animation (the final radius is zero)
    Animator anim = ViewAnimationUtils.createCircularReveal(myView, x, y, initialRadius, 0).setDuration(600);

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

    // start the animation
    anim.start();
}

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

private void showConversationLayout() {
    // get the final radius for the clipping circle
    int finalRadius = Math.max(roomsLayout.getWidth(), roomsLayout.getHeight());
    final FrameLayout colorLayout = (FrameLayout) findViewById(R.id.colorLayout);

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

        // create the animator for this view (the start radius is zero)
        Animator colorAnim;//  w w  w .  ja v a2 s  .c om
        colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) roomsLayout.getLeft(),
                (int) roomsLayout.getTop(), 0, finalRadius);
        final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f);
        fadeAnim.setDuration(250);
        fadeAnim.setInterpolator(new AccelerateInterpolator());
        fadeAnim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                conversationLayout.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                colorLayout.setVisibility(View.GONE);
                invalidateOptionsMenu();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        colorAnim.setInterpolator(new AccelerateInterpolator());
        colorAnim.addListener(new android.animation.Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(android.animation.Animator animation) {
            }

            @Override
            public void onAnimationRepeat(android.animation.Animator animation) {
            }

            @Override
            public void onAnimationEnd(android.animation.Animator animation) {
                colorLayout.startAnimation(fadeAnim);
            }

            @Override
            public void onAnimationCancel(android.animation.Animator animation) {
            }
        });

        colorLayout.setVisibility(View.VISIBLE);
        colorAnim.start();

    } else {
        conversationLayout.setVisibility(View.VISIBLE);
        conversationLayout.setAlpha(0.f);
        conversationLayout.setScaleX(0.f);
        conversationLayout.setScaleY(0.f);
        conversationLayout.animate().alpha(1.f).scaleX(1.f).scaleY(1.f).setDuration(300).start();
    }
}