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:org.huxizhijian.hhcomicviewer.ui.entry.ComicDetailsActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void animateRevealShow(View viewRoot) {
    //???/*w ww  .  ja v a 2  s. c  om*/
    int cx = (viewRoot.getLeft() + viewRoot.getRight()) / 2;
    int cy = (viewRoot.getTop() + viewRoot.getBottom()) / 2;
    //?
    int finalRadius = Math.max(viewRoot.getWidth(), viewRoot.getHeight());

    Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, cx, cy, 0, finalRadius);
    viewRoot.setVisibility(View.VISIBLE); //??
    anim.setDuration(getResources().getInteger(R.integer.anim_duration_medium));//
    anim.setInterpolator(new AccelerateInterpolator());//? ??
    anim.start();
}

From source file:io.vit.vitio.Fragments.SubjectView.SubjectViewFragmentTrial.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void circularRevealSchoolImage() {
    // previously invisible view

    // get the center for the clipping circle
    int cx = schoolImage.getMeasuredWidth() / 2;
    int cy = schoolImage.getMeasuredHeight() / 2;

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

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

    // make the view visible and start the animation
    schoolImage.setVisibility(View.VISIBLE);
    anim.start();/*from w  w w.  ja v  a2 s  .  c om*/
}

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

@OnClick({ R.id.scrim, R.id.searchback })
protected void dismiss() {
    // translate the icon to match position in the launching activity
    searchBackContainer.animate().translationX(searchBackDistanceX).setDuration(600L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in))
            .setListener(new AnimatorListenerAdapter() {
                @Override/* w  w w .j a v a 2 s.co  m*/
                public void onAnimationEnd(Animator animation) {
                    finishAfterTransition();
                }
            }).start();
    // transform from back icon to search icon
    AnimatedVectorDrawable backToSearch = (AnimatedVectorDrawable) ContextCompat.getDrawable(this,
            R.drawable.avd_back_to_search);
    searchBack.setImageDrawable(backToSearch);
    // clear the background else the touch ripple moves with the translation which looks bad
    searchBack.setBackground(null);
    backToSearch.start();
    // fade out the other search chrome
    searchView.animate().alpha(0f).setStartDelay(0L).setDuration(120L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in))
            .setListener(null).start();
    searchBackground.animate().alpha(0f).setStartDelay(300L).setDuration(160L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in))
            .setListener(null).start();
    if (searchToolbar.getZ() != 0f) {
        searchToolbar.animate().z(0f).setDuration(600L)
                .setInterpolator(
                        AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in))
                .start();
    }

    // if we're showing search results, circular hide them
    if (resultsContainer.getHeight() > 0) {
        Animator closeResults = ViewAnimationUtils.createCircularReveal(resultsContainer, searchIconCenterX, 0,
                (float) Math.hypot(searchIconCenterX, resultsContainer.getHeight()), 0f);
        closeResults.setDuration(500L);
        closeResults.setInterpolator(
                AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in));
        closeResults.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                resultsContainer.setVisibility(View.INVISIBLE);
            }
        });
        closeResults.start();
    }

    // fade out the scrim
    scrim.animate().alpha(0f).setDuration(400L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in))
            .setListener(null).start();
}

From source file:org.goodev.material.SearchActivity.java

@OnClick({ R.id.scrim, R.id.searchback })
protected void dismiss() {
    int interpolator = UI.isLollipop() ? android.R.interpolator.fast_out_slow_in
            : android.R.interpolator.accelerate_decelerate;
    int backInterpolator = UI.isLollipop() ? android.R.interpolator.fast_out_linear_in
            : android.R.interpolator.accelerate_decelerate;
    // translate the icon to match position in the launching activity
    searchBackContainer.animate().translationX(searchBackDistanceX).setDuration(600L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, interpolator))
            .setListener(new AnimatorListenerAdapter() {
                @Override// w w  w  .  ja va  2  s .  c  om
                public void onAnimationEnd(Animator animation) {
                    supportFinishAfterTransition();
                }
            }).start();
    if (UI.isLollipop()) {

        // transform from back icon to search icon
        AnimatedVectorDrawable backToSearch = (AnimatedVectorDrawable) ContextCompat.getDrawable(this,
                R.drawable.avd_back_to_search);
        searchBack.setImageDrawable(backToSearch);
        // clear the background else the touch ripple moves with the translation which looks bad
        searchBack.setBackground(null);
        backToSearch.start();
    }
    // fade out the other search chrome
    searchView.animate().alpha(0f).setStartDelay(0L).setDuration(120L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, backInterpolator)).setListener(null).start();
    searchBackground.animate().alpha(0f).setStartDelay(300L).setDuration(160L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, backInterpolator)).setListener(null).start();
    if (UI.isLollipop()) {
        if (searchToolbar.getZ() != 0f) {
            searchToolbar.animate().z(0f).setDuration(600L)
                    .setInterpolator(AnimationUtils.loadInterpolator(this, backInterpolator)).start();
        }

    }

    // if we're showing search results, circular hide them
    if (UI.isLollipop() && resultsContainer.getHeight() > 0) {
        Animator closeResults = ViewAnimationUtils.createCircularReveal(resultsContainer, searchIconCenterX, 0,
                (float) Math.hypot(searchIconCenterX, resultsContainer.getHeight()), 0f);
        closeResults.setDuration(500L);
        closeResults.setInterpolator(
                AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in));
        closeResults.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                resultsContainer.setVisibility(View.INVISIBLE);
            }
        });
        closeResults.start();
    }

    // fade out the scrim
    scrim.animate().alpha(0f).setDuration(400L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, backInterpolator)).setListener(null).start();
}

From source file:com.eugene.fithealthmaingit.UI.ChooseAddMealTabsFragment.java

private void handleSearchManual() {
    if (card_search_manual.getVisibility() == View.VISIBLE) {
        searchManual.setVisibility(View.VISIBLE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            final Animator animatorHide = ViewAnimationUtils.createCircularReveal(card_search_manual,
                    card_search_manual.getWidth() - (int) convertDpToPixel(24, getActivity()),
                    (int) convertDpToPixel(23, getActivity()),
                    (float) Math.hypot(card_search_manual.getWidth(), card_search_manual.getHeight()), 0);
            animatorHide.addListener(new Animator.AnimatorListener() {
                @Override//from  w w  w.j a  v  a2s.  com
                public void onAnimationStart(Animator animation) {

                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    card_search_manual.setVisibility(View.GONE);
                    ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                            .hideSoftInputFromWindow(searchManual.getWindowToken(), 0);
                }

                @Override
                public void onAnimationCancel(Animator animation) {

                }

                @Override
                public void onAnimationRepeat(Animator animation) {

                }
            });

            animatorHide.setDuration(200);
            animatorHide.start();
        } else {
            card_search_manual.setVisibility(View.GONE);
            ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(searchManual.getWindowToken(), 0);
        }
    } else {
        searchManual.setVisibility(View.INVISIBLE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            final Animator animator = ViewAnimationUtils.createCircularReveal(card_search_manual,
                    card_search_manual.getWidth() - (int) convertDpToPixel(24, getActivity()),
                    (int) convertDpToPixel(23, getActivity()), 0,
                    (float) Math.hypot(card_search_manual.getWidth(), card_search_manual.getHeight()));
            animator.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animation) {
                    manualSearch.requestFocus();
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    ((InputMethodManager) getActivity().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) {

                }
            });
            card_search_manual.setVisibility(View.VISIBLE);
            if (card_search_manual.getVisibility() == View.VISIBLE) {
                animator.setDuration(300);
                animator.start();
                card_search_manual.setEnabled(true);
            }
        } else {
            manualSearch.requestFocus();
            ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                    .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
            card_search_manual.setVisibility(View.VISIBLE);
        }
    }
}

From source file:com.hannesdorfmann.search.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/*from w w  w.  j  ava2 s  .co m*/
          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.ui.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/*from   w  ww.j a  v a2  s.c o m*/
        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:com.syncedsynapse.kore2.utils.UIUtils.java

/**
 * Launches the remote activity, performing a circular reveal animation if
 * Lollipop or later/*from   ww w .j  a v  a  2  s.  c om*/
 *
 * @param context Context
 * @param centerX Center X of the animation
 * @param centerY Center Y of the animation
 * @param exitTransitionView View to reveal. Should occupy the whole screen and
 *                           be invisible before calling this
 */
@TargetApi(21)
public static void switchToRemoteWithAnimation(final Context context, int centerX, int centerY,
        final View exitTransitionView) {
    final Intent launchIntent = new Intent(context, RemoteActivity.class);
    if (Utils.isLollipopOrLater()) {
        // Show the animation
        int endRadius = Math.max(exitTransitionView.getHeight(), exitTransitionView.getWidth());
        Animator exitAnim = ViewAnimationUtils.createCircularReveal(exitTransitionView, centerX, centerY, 0,
                endRadius);

        exitAnim.setDuration(200);
        exitAnim.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                // Launch remote activity
                context.startActivity(launchIntent);
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }
        });
        exitTransitionView.setVisibility(View.VISIBLE);
        exitAnim.start();
    } else {
        // No animation show, just launch the remote
        context.startActivity(launchIntent);
    }
}

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

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@ProtocoderScript//from  w w w .  j  a v a  2  s . c  o m
@APIParam(params = { "View" })
public void reveal(final View v) {
    // previously invisible view

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

    // get the final radius for the clipping circle
    int finalRadius = v.getWidth();

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

    anim.setDuration(1000);
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            v.setVisibility(View.VISIBLE);
        }
    });
    anim.start();
}

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

@OnClick({ R.id.scrim, R.id.searchback })
protected void dismiss() {
    // translate the icon to match position in the launching activity
    searchBackContainer.animate().translationX(searchBackDistanceX).setDuration(600L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in))
            .setListener(new AnimatorListenerAdapter() {

                @Override//from ww w .  j a  v a 2  s . c o m
                public void onAnimationEnd(Animator animation) {
                    finishAfterTransition();
                }
            }).start();
    // transform from back icon to search icon
    AnimatedVectorDrawable backToSearch = (AnimatedVectorDrawable) ContextCompat.getDrawable(this,
            R.drawable.avd_back_to_search);
    searchBack.setImageDrawable(backToSearch);
    // clear the background else the touch ripple moves with the translation which looks bad
    searchBack.setBackground(null);
    backToSearch.start();
    // fade out the other search chrome
    searchView.animate().alpha(0f).setStartDelay(0L).setDuration(120L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in))
            .setListener(null).start();
    searchBackground.animate().alpha(0f).setStartDelay(300L).setDuration(160L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in))
            .setListener(null).start();
    if (searchToolbar.getZ() != 0f) {
        searchToolbar.animate().z(0f).setDuration(600L)
                .setInterpolator(
                        AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in))
                .start();
    }

    // if we're showing search results, circular hide them
    if (resultsContainer.getHeight() > 0) {
        Animator closeResults = ViewAnimationUtils.createCircularReveal(resultsContainer, searchIconCenterX, 0,
                (float) Math.hypot(searchIconCenterX, resultsContainer.getHeight()), 0f);
        closeResults.setDuration(500L);
        closeResults.setInterpolator(
                AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in));
        closeResults.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                resultsContainer.setVisibility(View.INVISIBLE);
            }
        });
        closeResults.start();
    }

    // fade out the scrim
    scrim.animate().alpha(0f).setDuration(400L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in))
            .setListener(null).start();
}