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:shetye.prathamesh.notifyme.Utilities.java

public void hideView(final LinearLayout lview) {
    // get the center for the clipping circle
    int cx = (lview.getLeft() + lview.getRight()) / 2;
    int cy = (lview.getTop() + lview.getBottom()) / 2;
    // get the initial radius for the clipping circle
    int initialRadius = lview.getWidth();
    // create the animation (the final radius is zero)
    Animator anim = ViewAnimationUtils.createCircularReveal(lview, cx, cy, initialRadius, 0);
    // make the view invisible when the animation is done
    anim.addListener(new AnimatorListenerAdapter() {
        @Override//ww  w  .  j av a 2  s .c o m
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            lview.setVisibility(View.INVISIBLE);
        }
    });
    anim.start();
}

From source file:org.protocoderrunner.apprunner.api.PUI.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@ProtocoderScript/*from w ww.  j ava2  s  . com*/
@APIParam(params = { "View" })
public void unreveal(final View v) {

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

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

    // create the animation (the final radius is zero)
    ValueAnimator anim = (ValueAnimator) ViewAnimationUtils.createCircularReveal(v, cx, cy, initialRadius, 0);
    anim.setDuration(1000);

    // make the view invisible when the animation is done
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            v.setVisibility(View.INVISIBLE);
        }
    });

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

From source file:shetye.prathamesh.notifyme.Utilities.java

public void showView(LinearLayout lview) {
    // get the center for the clipping circle
    int cx = (lview.getLeft() + lview.getRight()) / 2;
    int cy = (lview.getTop() + lview.getBottom()) / 2;
    // get the final radius for the clipping circle
    int finalRadius = Math.max(lview.getWidth(), lview.getHeight());
    // create the animator for this view (the start radius is zero)
    Animator anim = ViewAnimationUtils.createCircularReveal(lview, cx, cy, 0, finalRadius);
    // make the view visible and start the animation
    lview.setVisibility(View.VISIBLE);
    anim.start();/*w  w  w.j av  a  2s. c  o  m*/
}

From source file:de.janniskilian.xkcdreader.presentation.components.showcomics.ShowComicsActivity.java

@Override
public void endSearchMode(boolean animate) {
    Utils.hideKeyboard(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (animate) {
            // If the device has rotated, we need to calculate a new center for the animation.
            if (searchButtonCenter == null) {
                final View actionMenuView = searchToolbar.getChildAt(2);
                final ViewGroup actionMenuViewGroup = (ViewGroup) actionMenuView;
                final View button = actionMenuViewGroup.getChildAt(0);
                System.out.println(button.getClass());

                searchButtonCenter = new Point(
                        (int) (button.getX() + actionMenuView.getX() - button.getWidth() / 2),
                        (int) (button.getY() + actionMenuView.getY() + button.getHeight() / 2));
            }/*w w  w  .ja va2  s .  c  o  m*/

            final Animator animator = ViewAnimationUtils.createCircularReveal(searchToolbar,
                    searchButtonCenter.x, searchButtonCenter.y, searchToolbar.getWidth(), 0);
            animator.setDuration(revealStatusBarDuration);
            animator.addListener(new EndSearchModeAnimationListener(searchToolbar));
            toolbar.setVisibility(View.VISIBLE);
            animator.start();
        } else {
            searchToolbar.setVisibility(View.INVISIBLE);
        }

        setSupportActionBar(toolbar);
    } else {
        toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.primary));

        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setHomeButtonEnabled(false);
            actionBar.setDisplayHomeAsUpEnabled(false);
            actionBar.setCustomView(R.layout.toolbar_search);
            actionBar.setDisplayShowCustomEnabled(false);
            actionBar.setDisplayShowTitleEnabled(true);
        }
    }

    viewPager.setVisibility(View.VISIBLE);
    if (animate) {
        searchResults.animate().alpha(0).setDuration(crossfadeViewPagerSearchDuration)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        searchResults.setVisibility(View.GONE);
                    }
                });

        viewPager.animate().alpha(1).setDuration(crossfadeViewPagerSearchDuration).setListener(null);
    } else {
        viewPager.setAlpha(1);
        searchResults.setAlpha(0);
        searchResults.setVisibility(View.GONE);
    }

    searchInputSub.unsubscribe();
    searchInputLengthSub.unsubscribe();
    invalidateOptionsMenu();
}

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

private void doFabExpand() {
    // translate the chrome placeholder ui so that it is centered on the FAB
    int fabCenterX = (fab.getLeft() + fab.getRight()) / 2;
    int fabCenterY = ((fab.getTop() + fab.getBottom()) / 2) - fabExpand.getTop();
    int translateX = fabCenterX - (fabExpand.getWidth() / 2);
    int translateY = fabCenterY - (fabExpand.getHeight() / 2);
    fabExpand.setTranslationX(translateX);
    fabExpand.setTranslationY(translateY);

    // then reveal the placeholder ui, starting from the center & same dimens as fab
    fabExpand.setVisibility(View.VISIBLE);
    Animator reveal = ViewAnimationUtils
            .createCircularReveal(fabExpand, fabExpand.getWidth() / 2, fabExpand.getHeight() / 2,
                    fab.getWidth() / 2, (int) Math.hypot(fabExpand.getWidth() / 2, fabExpand.getHeight() / 2))
            .setDuration(fabExpandDuration);

    // translate the placeholder ui back into position along an arc
    ArcMotion arcMotion = new ArcMotion();
    arcMotion.setMinimumVerticalAngle(70f);
    Path motionPath = arcMotion.getPath(translateX, translateY, 0, 0);
    Animator position = ObjectAnimator.ofFloat(fabExpand, View.TRANSLATION_X, View.TRANSLATION_Y, motionPath)
            .setDuration(fabExpandDuration);

    // animate from the FAB colour to the placeholder background color
    Animator background = ObjectAnimator
            .ofArgb(fabExpand, ViewUtils.BACKGROUND_COLOR, ContextCompat.getColor(this, R.color.designer_news),
                    ContextCompat.getColor(this, R.color.background_light))
            .setDuration(fabExpandDuration);

    // fade out the fab (rapidly)
    Animator fadeOutFab = ObjectAnimator.ofFloat(fab, View.ALPHA, 0f).setDuration(60);

    // play 'em all together with the material interpolator
    AnimatorSet show = new AnimatorSet();
    show.setInterpolator(/*from   w  ww.  j a v a 2s  .c  o m*/
            AnimationUtils.loadInterpolator(DesignerNewsStory.this, android.R.interpolator.fast_out_slow_in));
    show.playTogether(reveal, background, position, fadeOutFab);
    show.start();
}

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

private void doFabExpand() {
    // translate the chrome placeholder ui so that it is centered on the FAB
    int fabCenterX = (fab.getLeft() + fab.getRight()) / 2;
    int fabCenterY = ((fab.getTop() + fab.getBottom()) / 2) - fabExpand.getTop();
    int translateX = fabCenterX - (fabExpand.getWidth() / 2);
    int translateY = fabCenterY - (fabExpand.getHeight() / 2);
    fabExpand.setTranslationX(translateX);
    fabExpand.setTranslationY(translateY);

    // then reveal the placeholder ui, starting from the center & same dimens as fab
    fabExpand.setVisibility(View.VISIBLE);
    Animator reveal = ViewAnimationUtils
            .createCircularReveal(fabExpand, fabExpand.getWidth() / 2, fabExpand.getHeight() / 2,
                    fab.getWidth() / 2, (int) Math.hypot(fabExpand.getWidth() / 2, fabExpand.getHeight() / 2))
            .setDuration(fabExpandDuration);

    // translate the placeholder ui back into position along an arc
    GravityArcMotion arcMotion = new GravityArcMotion();
    arcMotion.setMinimumVerticalAngle(70f);
    Path motionPath = arcMotion.getPath(translateX, translateY, 0, 0);
    Animator position = ObjectAnimator.ofFloat(fabExpand, View.TRANSLATION_X, View.TRANSLATION_Y, motionPath)
            .setDuration(fabExpandDuration);

    // animate from the FAB colour to the placeholder background color
    Animator background = ObjectAnimator
            .ofArgb(fabExpand, ViewUtils.BACKGROUND_COLOR, ContextCompat.getColor(this, R.color.designer_news),
                    ContextCompat.getColor(this, R.color.background_light))
            .setDuration(fabExpandDuration);

    // fade out the fab (rapidly)
    Animator fadeOutFab = ObjectAnimator.ofFloat(fab, View.ALPHA, 0f).setDuration(60);

    // play 'em all together with the material interpolator
    AnimatorSet show = new AnimatorSet();
    show.setInterpolator(getFastOutSlowInInterpolator(DesignerNewsStory.this));
    show.playTogether(reveal, background, position, fadeOutFab);
    show.start();/*from   w w  w.  j  a  v a  2 s.com*/
}

From source file:babbq.com.searchplace.SearchActivity.java

@OnClick(R.id.fab)
protected void save() {
    // show the save confirmation bubble
    fab.setVisibility(View.INVISIBLE);
    confirmSaveContainer.setVisibility(View.VISIBLE);
    resultsScrim.setVisibility(View.VISIBLE);

    // expand it once it's been measured and show a scrim over the search results
    confirmSaveContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

        @Override//  w ww.j av  a  2s  .  c  om
        public boolean onPreDraw() {
            // expand the confirmation
            confirmSaveContainer.getViewTreeObserver().removeOnPreDrawListener(this);
            Animator reveal = ViewAnimationUtils.createCircularReveal(confirmSaveContainer,
                    confirmSaveContainer.getWidth() / 2, confirmSaveContainer.getHeight() / 2,
                    fab.getWidth() / 2, confirmSaveContainer.getWidth() / 2);
            reveal.setDuration(250L);
            reveal.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                    android.R.interpolator.fast_out_slow_in));
            reveal.start();

            // show the scrim
            int centerX = (fab.getLeft() + fab.getRight()) / 2;
            int centerY = (fab.getTop() + fab.getBottom()) / 2;
            Animator revealScrim = ViewAnimationUtils.createCircularReveal(resultsScrim, centerX, centerY, 0,
                    (float) Math.hypot(centerX, centerY));
            revealScrim.setDuration(400L);
            revealScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                    android.R.interpolator.linear_out_slow_in));
            revealScrim.start();
            ObjectAnimator fadeInScrim = ObjectAnimator.ofArgb(resultsScrim, ViewUtils.BACKGROUND_COLOR,
                    Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim));
            fadeInScrim.setDuration(800L);
            fadeInScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                    android.R.interpolator.linear_out_slow_in));
            fadeInScrim.start();

            // ease in the checkboxes
            //                saveDribbble.setAlpha(0.6f);
            //                saveDribbble.setTranslationY(saveDribbble.getHeight() * 0.4f);
            //                saveDribbble.animate()
            //                        .alpha(1f)
            //                        .translationY(0f)
            //                        .setDuration(200L)
            //                        .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
            //                                android.R.interpolator.linear_out_slow_in));
            //                saveDesignerNews.setAlpha(0.6f);
            //                saveDesignerNews.setTranslationY(saveDesignerNews.getHeight() * 0.5f);
            //                saveDesignerNews.animate()
            //                        .alpha(1f)
            //                        .translationY(0f)
            //                        .setDuration(200L)
            //                        .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
            //                                android.R.interpolator.linear_out_slow_in));
            return false;
        }
    });
}

From source file:io.plaidapp.designernews.ui.story.StoryActivity.java

private void doFabExpand() {
    // translate the chrome placeholder ui so that it is centered on the FAB
    int fabCenterX = (fab.getLeft() + fab.getRight()) / 2;
    int fabCenterY = ((fab.getTop() + fab.getBottom()) / 2) - fabExpand.getTop();
    int translateX = fabCenterX - (fabExpand.getWidth() / 2);
    int translateY = fabCenterY - (fabExpand.getHeight() / 2);
    fabExpand.setTranslationX(translateX);
    fabExpand.setTranslationY(translateY);

    // then reveal the placeholder ui, starting from the center & same dimens as fab
    fabExpand.setVisibility(View.VISIBLE);
    Animator reveal = ViewAnimationUtils
            .createCircularReveal(fabExpand, fabExpand.getWidth() / 2, fabExpand.getHeight() / 2,
                    fab.getWidth() / 2, (int) Math.hypot(fabExpand.getWidth() / 2, fabExpand.getHeight() / 2))
            .setDuration(fabExpandDuration);

    // translate the placeholder ui back into position along an arc
    GravityArcMotion arcMotion = new GravityArcMotion();
    arcMotion.setMinimumVerticalAngle(70f);
    Path motionPath = arcMotion.getPath(translateX, translateY, 0, 0);
    Animator position = ObjectAnimator.ofFloat(fabExpand, View.TRANSLATION_X, View.TRANSLATION_Y, motionPath)
            .setDuration(fabExpandDuration);

    // animate from the FAB colour to the placeholder background color
    Animator background = ObjectAnimator
            .ofArgb(fabExpand, ViewUtils.BACKGROUND_COLOR,
                    ContextCompat.getColor(this, io.plaidapp.R.color.designer_news),
                    ContextCompat.getColor(this, io.plaidapp.R.color.background_light))
            .setDuration(fabExpandDuration);

    // fade out the fab (rapidly)
    Animator fadeOutFab = ObjectAnimator.ofFloat(fab, View.ALPHA, 0f).setDuration(60);

    // play 'em all together with the material interpolator
    AnimatorSet show = new AnimatorSet();
    show.setInterpolator(getFastOutSlowInInterpolator(StoryActivity.this));
    show.playTogether(reveal, background, position, fadeOutFab);
    show.start();/*www .j  av  a  2s  .co m*/
}

From source file:com.hannesdorfmann.search.SearchActivity.java

@OnClick(R.id.results_scrim)
  protected void hideSaveConfimation() {
      if (confirmSaveContainer.getVisibility() == View.VISIBLE) {
          // contract the bubble & hide the scrim
          AnimatorSet hideConfirmation = new AnimatorSet();
          hideConfirmation.playTogether(
                  ViewAnimationUtils.createCircularReveal(confirmSaveContainer,
                          confirmSaveContainer.getWidth() / 2, confirmSaveContainer.getHeight() / 2,
                          confirmSaveContainer.getWidth() / 2, fab.getWidth() / 2),
                  ObjectAnimator.ofArgb(resultsScrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT));
          hideConfirmation.setDuration(150L);
          hideConfirmation.setInterpolator(
                  AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in));
          hideConfirmation.addListener(new AnimatorListenerAdapter() {
              @Override//www  .  j  av  a  2s .  c  om
              public void onAnimationEnd(Animator animation) {
                  confirmSaveContainer.setVisibility(View.GONE);
                  resultsScrim.setVisibility(View.GONE);
                  fab.setVisibility(results.getVisibility());
              }
          });
          hideConfirmation.start();
      }
  }

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

@OnClick(R.id.results_scrim)
protected void hideSaveConfimation() {
    if (confirmSaveContainer.getVisibility() == View.VISIBLE) {
        // contract the bubble & hide the scrim
        AnimatorSet hideConfirmation = new AnimatorSet();
        hideConfirmation.playTogether(//from w w w  .  j a v  a  2  s.c  om
                ViewAnimationUtils.createCircularReveal(confirmSaveContainer,
                        confirmSaveContainer.getWidth() / 2, confirmSaveContainer.getHeight() / 2,
                        confirmSaveContainer.getWidth() / 2, fab.getWidth() / 2),
                ObjectAnimator.ofArgb(resultsScrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT));
        hideConfirmation.setDuration(150L);
        hideConfirmation.setInterpolator(
                AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in));
        hideConfirmation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                confirmSaveContainer.setVisibility(View.GONE);
                resultsScrim.setVisibility(View.GONE);
                fab.setVisibility(results.getVisibility());
            }
        });
        hideConfirmation.start();
    }
}