Example usage for android.view.animation AnimationUtils loadInterpolator

List of usage examples for android.view.animation AnimationUtils loadInterpolator

Introduction

In this page you can find the example usage for android.view.animation AnimationUtils loadInterpolator.

Prototype

public static Interpolator loadInterpolator(Context context, @AnimRes @InterpolatorRes int id)
        throws NotFoundException 

Source Link

Document

Loads an Interpolator object from a resource

Usage

From source file:systems.soapbox.ombuds.client.ui.omb.SearchActivity.java

/**
 * On Lollipop+ perform a circular reveal animation (an expanding circular mask) when showing
 * the search panel./*ww  w.  j  a  v a2  s  . c o  m*/
 *
 * Support CircularReveal :
 * https://github.com/ozodrukh/CircularReveal
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doEnterAnim() {
    // Fade in a background scrim as this is a floating window. We could have used a
    // translucent window background but this approach allows us to turn off window animation &
    // overlap the fade with the reveal animation  making it feel snappier.
    View scrim = findViewById(R.id.scrim);
    scrim.animate().alpha(1f).setDuration(500L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in))
            .start();

    // Next perform the circular reveal on the search panel
    final View searchPanel = findViewById(R.id.search_panel);
    if (searchPanel != null) {
        // We use a view tree observer to set this up once the view is measured & laid out
        searchPanel.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                searchPanel.getViewTreeObserver().removeOnPreDrawListener(this);
                // As the height will change once the initial suggestions are delivered by the
                // loader, we can't use the search panels height to calculate the final radius
                // so we fall back to it's parent to be safe
                int revealRadius = ((ViewGroup) searchPanel.getParent()).getHeight();
                // Center the animation on the top right of the panel i.e. near to the
                // search button which launched this screen.
                Animator show = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(),
                        searchPanel.getTop(), 0f, revealRadius);
                show.setDuration(350L);
                show.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                        android.R.interpolator.fast_out_slow_in));
                show.start();
                return false;
            }
        });
    }
}

From source file:com.base.view.slidemenu.SlideMenu.java

public SlideMenu(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // we want to draw drop shadow of content
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mVelocityTracker = VelocityTracker.obtain();
    mContentHitRect = new Rect();
    mEdgeSlideDetectRect = new Rect();
    STATUS_BAR_HEIGHT = (int) getStatusBarHeight(context);
    setWillNotDraw(false);/*from w w  w . j  a  va  2 s.c o m*/

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlideMenu, defStyle, 0);

    // Set the shadow attributes
    setPrimaryShadowWidth(a.getDimension(R.styleable.SlideMenu_primaryShadowWidth, 30));
    setSecondaryShadowWidth(a.getDimension(R.styleable.SlideMenu_secondaryShadowWidth, 30));

    Drawable primaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_primaryShadowDrawable);
    if (null == primaryShadowDrawable) {
        primaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT,
                new int[] { Color.TRANSPARENT, Color.argb(99, 0, 0, 0) });
    }
    setPrimaryShadowDrawable(primaryShadowDrawable);

    Drawable secondaryShadowDrawable = a.getDrawable(R.styleable.SlideMenu_secondaryShadowDrawable);
    if (null == secondaryShadowDrawable) {
        secondaryShadowDrawable = new GradientDrawable(Orientation.LEFT_RIGHT,
                new int[] { Color.argb(99, 0, 0, 0), Color.TRANSPARENT });
    }
    setSecondaryShadowDrawable(secondaryShadowDrawable);

    int interpolatorResId = a.getResourceId(R.styleable.SlideMenu_interpolator, -1);
    setInterpolator(-1 == interpolatorResId ? DEFAULT_INTERPOLATOR
            : AnimationUtils.loadInterpolator(context, interpolatorResId));

    mSlideDirectionFlag = a.getInt(R.styleable.SlideMenu_slideDirection,
            FLAG_DIRECTION_LEFT | FLAG_DIRECTION_RIGHT);

    setEdgeSlideEnable(a.getBoolean(R.styleable.SlideMenu_edgeSlide, false));
    setEdgetSlideWidth(a.getDimensionPixelSize(R.styleable.SlideMenu_edgeSlideWidth, 100));
    a.recycle();

    setFocusable(true);
    setFocusableInTouchMode(true);
}

From source file:com.google.samples.apps.iosched.ui.SearchActivity.java

/**
 * On Lollipop+ perform a circular reveal animation (an expanding circular mask) when showing
 * the search panel.//from   w  ww . j a  va2  s. co m
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doEnterAnim() {
    // Fade in a background scrim as this is a floating window. We could have used a
    // translucent window background but this approach allows us to turn off window animation &
    // overlap the fade with the reveal animation  making it feel snappier.
    View scrim = findViewById(R.id.scrim);
    scrim.animate().alpha(1f).setDuration(500L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in))
            .start();

    // Next perform the circular reveal on the search panel
    final View searchPanel = findViewById(R.id.search_panel);
    if (searchPanel != null) {
        // We use a view tree observer to set this up once the view is measured & laid out
        searchPanel.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                searchPanel.getViewTreeObserver().removeOnPreDrawListener(this);
                // As the height will change once the initial suggestions are delivered by the
                // loader, we can't use the search panels height to calculate the final radius
                // so we fall back to it's parent to be safe
                int revealRadius = ((ViewGroup) searchPanel.getParent()).getHeight();
                // Center the animation on the top right of the panel i.e. near to the
                // search button which launched this screen.
                Animator show = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(),
                        searchPanel.getTop(), 0f, revealRadius);
                show.setDuration(250L);
                show.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                        android.R.interpolator.fast_out_slow_in));
                show.start();
                return false;
            }
        });
    }
}

From source file:org.mozilla.focus.widget.AnimatedProgressBar.java

private Drawable buildWrapDrawable(Drawable original, boolean isWrap, int duration, int resID) {
    if (isWrap) {
        final Interpolator interpolator = (resID > 0) ? AnimationUtils.loadInterpolator(getContext(), resID)
                : null;/*www. ja  va2s .  c om*/
        final ShiftDrawable wrappedDrawable = new ShiftDrawable(original, duration, interpolator);
        return wrappedDrawable;
    } else {
        return original;
    }
}

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

@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_search);
      setRetainInstance(true);/*from   ww w.  ja v a 2  s.c o  m*/

      ButterKnife.bind(this);
      setupSearchView();

      auto = TransitionInflater.from(this).inflateTransition(R.transition.auto);
      adapter = new FeedAdapter(this, columns, PocketUtils.isPocketInstalled(this));

      results.setAdapter(adapter);
      GridLayoutManager layoutManager = new GridLayoutManager(this, columns);
      layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
          @Override
          public int getSpanSize(int position) {
              return adapter.getItemColumnSpan(position);
          }
      });
      results.setLayoutManager(layoutManager);
      results.addOnScrollListener(new InfiniteScrollListener(layoutManager) {
          @Override
          public void onLoadMore() {
              if (!adapter.isLoadingMore()) {
                  presenter.searchMore(searchView.getQuery().toString());
              }
          }
      });
      results.setHasFixedSize(true);
      results.addOnScrollListener(gridScroll);

      // extract the search icon's location passed from the launching activity, minus 4dp to
      // compensate for different paddings in the views
      searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue
              .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
      searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0);

      // translate icon to match the launching screen then animate back into position
      searchBackContainer.setTranslationX(searchBackDistanceX);
      searchBackContainer.animate().translationX(0f).setDuration(650L)
              .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in));
      // transform from search icon to back icon
      AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this,
              R.drawable.avd_search_to_back);
      searchBack.setImageDrawable(searchToBack);
      searchToBack.start();
      // for some reason the animation doesn't always finish (leaving a part arrow!?) so after
      // the animation set a static drawable. Also animation callbacks weren't added until API23
      // so using post delayed :(
      // TODO fix properly!!
      searchBack.postDelayed(new Runnable() {
          @Override
          public void run() {
              searchBack.setImageDrawable(
                      ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded));
          }
      }, 600);

      // fade in the other search chrome
      searchBackground.animate().alpha(1f).setDuration(300L)
              .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in));
      searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L)
              .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in))
              .setListener(new AnimatorListenerAdapter() {
                  @Override
                  public void onAnimationEnd(Animator animation) {
                      searchView.requestFocus();
                      ImeUtils.showIme(searchView);
                  }
              });

      // animate in a scrim over the content behind
      scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
          @Override
          public boolean onPreDraw() {
              scrim.getViewTreeObserver().removeOnPreDrawListener(this);
              AnimatorSet showScrim = new AnimatorSet();
              showScrim.playTogether(
                      ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX,
                              searchBackground.getBottom(), 0,
                              (float) Math.hypot(searchBackDistanceX,
                                      scrim.getHeight() - searchBackground.getBottom())),
                      ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT,
                              ContextCompat.getColor(SearchActivity.this, R.color.scrim)));
              showScrim.setDuration(400L);
              showScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                      android.R.interpolator.linear_out_slow_in));
              showScrim.start();
              return false;
          }
      });
      onNewIntent(getIntent());
  }

From source file:de.cellular.lib.lightlib.ui.fragment.LLRequestingFragment.java

protected void startRotate3dAnimationOut() {
    // Initialize the animations.
    Display display = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE))
            .getDefaultDisplay();/*from   w w w.j  a v a  2s  .  co  m*/
    int h2 = display.getHeight() / 2;
    int w2 = display.getWidth() / 2;

    Rotate3dAnimation outAnim = new Rotate3dAnimation(0, 90, w2, h2, 0.0f, false);
    outAnim.setDuration(FLIP_ANIMATION_DURATION_OUT);
    outAnim.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation _animation) {
        }

        @Override
        public void onAnimationRepeat(Animation _animation) {
        }

        @Override
        public void onAnimationEnd(Animation _animation) {
            if (getView() != null)
                getView().setVisibility(View.GONE);
        }
    });

    Rotate3dAnimation inAnim = new Rotate3dAnimation(-90, 0, w2, h2, 0.0f, false);
    inAnim.setDuration(FLIP_ANIMATION_DURATION_IN);
    inAnim.setStartOffset(FLIP_ANIMATION_DURATION_OUT);
    inAnim.setInterpolator(
            AnimationUtils.loadInterpolator(getActivity(), android.R.anim.decelerate_interpolator));
    outAnim.setInterpolator(
            AnimationUtils.loadInterpolator(getActivity(), android.R.anim.accelerate_interpolator));

    if (getView() != null)
        getView().startAnimation(outAnim);
}

From source file:com.josecalles.porridge.widget.BottomSheet.java

@Override
public void onStopNestedScroll(View child) {
    final int dragDisplacement = dragView.getTop() - dragViewTop;
    if (dragDisplacement == 0)
        return;//  w ww  .  ja  v  a  2 s.co  m

    // check if we should perform a dismiss or settle back into place
    final boolean dismiss = lastNestedScrollWasDownward && dragDisplacement >= dragDismissDistance;
    // animate either back into place or to bottom
    ObjectAnimator settleAnim = ObjectAnimator.ofInt(dragViewOffsetHelper, ViewOffsetHelper.OFFSET_Y,
            dragView.getTop(), dismiss ? dragViewBottom : dragViewTop);
    settleAnim.setDuration(200L);
    settleAnim.setInterpolator(
            AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.fast_out_slow_in));
    if (dismiss) {
        settleAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                dispatchDismissCallback();
            }
        });
    }
    settleAnim.start();
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    ButterKnife.bind(this);
    setupSearchView();/*from  w w w .  j  a va2 s .  c o m*/
    auto = TransitionInflater.from(this).inflateTransition(R.transition.auto);

    mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API)
            .addApi(Places.GEO_DATA_API).addConnectionCallbacks(this).addOnConnectionFailedListener(this)
            .build();

    mAdapter = new TestAdapter(null, v -> {
        int position = results.getChildLayoutPosition(v);
        //Toast.makeText(getActivity(), "#" + position, Toast.LENGTH_SHORT).show();
        PendingResult result = Places.GeoDataApi.getPlaceById(mGoogleApiClient,
                String.valueOf(mAdapter.getElementAt(position).placeId));
        result.setResultCallback(mCoordinatePlaceDetailsCallback);
    }, mGoogleApiClient);

    dataManager = new SearchDataManager(mGoogleApiClient, mCoordinatePlaceDetailsCallback) {

        @Override
        public void onDataLoaded(List<? extends PlaceAutocomplete> data) {
            if (data != null && data.size() > 0) {
                if (results.getVisibility() != View.VISIBLE) {
                    TransitionManager.beginDelayedTransition(container, auto);
                    progress.setVisibility(View.GONE);
                    results.setVisibility(View.VISIBLE);
                    //                        fab.setVisibility(View.VISIBLE);
                    fab.setAlpha(0.6f);
                    fab.setScaleX(0f);
                    fab.setScaleY(0f);
                    fab.animate().alpha(1f).scaleX(1f).scaleY(1f).setStartDelay(800L).setDuration(300L)
                            .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                                    android.R.interpolator.linear_out_slow_in));
                }
                //                    mAdapter.addAndResort(data);
                mAdapter.setList(data);
            } else {
                TransitionManager.beginDelayedTransition(container, auto);
                progress.setVisibility(View.GONE);
                setNoResultsVisibility(View.VISIBLE);
            }
        }
    };
    //        mAdapter = new FeedAdapter(this, dataManager, columns);
    results.setAdapter(mAdapter);
    GridLayoutManager layoutManager = new GridLayoutManager(this, columns);
    //        layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
    //
    //            @Override
    //            public int getSpanSize(int position) {
    //                return mAdapter.getItemColumnSpan(position);
    //            }
    //        });
    results.setLayoutManager(layoutManager);
    results.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {

        @Override
        public void onLoadMore() {
            dataManager.loadMore();
        }
    });
    results.setHasFixedSize(true);
    results.addOnScrollListener(gridScroll);

    // extract the search icon's location passed from the launching activity, minus 4dp to
    // compensate for different paddings in the views
    searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
    searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0);

    // translate icon to match the launching screen then animate back into position
    searchBackContainer.setTranslationX(searchBackDistanceX);
    searchBackContainer.animate().translationX(0f).setDuration(650L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in));
    // transform from search icon to back icon
    AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this,
            R.drawable.avd_search_to_back);
    searchBack.setImageDrawable(searchToBack);
    searchToBack.start();
    // for some reason the animation doesn't always finish (leaving a part arrow!?) so after
    // the animation set a static drawable. Also animation callbacks weren't added until API23
    // so using post delayed :(
    // TODO fix properly!!
    searchBack.postDelayed(new Runnable() {

        @Override
        public void run() {
            searchBack.setImageDrawable(
                    ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded));
        }
    }, 600);

    // fade in the other search chrome
    searchBackground.animate().alpha(1f).setDuration(300L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in));
    searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in))
            .setListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    searchView.requestFocus();
                    ImeUtils.showIme(searchView);
                }
            });

    // animate in a scrim over the content behind
    scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            scrim.getViewTreeObserver().removeOnPreDrawListener(this);
            AnimatorSet showScrim = new AnimatorSet();
            showScrim.playTogether(
                    ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX,
                            searchBackground.getBottom(), 0,
                            (float) Math.hypot(searchBackDistanceX,
                                    scrim.getHeight() - searchBackground.getBottom())),
                    ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT,
                            ContextCompat.getColor(SearchActivity.this, R.color.scrim)));
            showScrim.setDuration(400L);
            showScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                    android.R.interpolator.linear_out_slow_in));
            showScrim.start();
            return false;
        }
    });
    onNewIntent(getIntent());
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    ButterKnife.bind(this);
    setupSearchView();//from w  w  w .  j  av  a 2s  . co m
    if (UI.isLollipop()) {
        auto = TransitionInflater.from(this).inflateTransition(R.transition.auto);
    }

    dataManager = new SearchDataManager(this) {
        @Override
        public void onDataLoaded(List<Hit> data) {
            if (data != null && data.size() > 0) {
                if (results.getVisibility() != View.VISIBLE) {
                    if (UI.isLollipop()) {
                        TransitionManager.beginDelayedTransition(container, auto);
                    }
                    progress.setVisibility(View.GONE);
                    results.setVisibility(View.VISIBLE);
                }
                adapter.addAll(data);
                if (dataManager.getPage() == 0) {
                    results.scrollToPosition(0);
                }
            } else if (adapter.getItemCount() == 0) {
                if (UI.isLollipop()) {
                    TransitionManager.beginDelayedTransition(container, auto);
                }
                progress.setVisibility(View.GONE);
                setNoResultsVisibility(View.VISIBLE);
            } else {
                adapter.notifyDataSetChanged();
                Snackbar.make(results, R.string.no_more_posts, Snackbar.LENGTH_LONG).show();
            }
        }
    };
    adapter = new FeedAdapter(this, dataManager, columns);
    results.setAdapter(adapter);
    GridLayoutManager layoutManager = new GridLayoutManager(this, columns);
    //        layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
    //            @Override
    //            public int getSpanSize(int position) {
    //                return adapter.getItemColumnSpan(position);
    //            }
    //        });
    results.setLayoutManager(layoutManager);
    results.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {
        @Override
        public void onLoadMore() {
            dataManager.loadMore();
        }
    });
    results.setHasFixedSize(true);
    if (UI.isLollipop()) {
        results.addOnScrollListener(gridScroll);
    }

    // extract the search icon's location passed from the launching activity, minus 4dp to
    // compensate for different paddings in the views
    searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics());
    searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0);

    int interpolator = UI.isLollipop() ? android.R.interpolator.fast_out_slow_in
            : android.R.interpolator.accelerate_decelerate;
    int backInterpolator = UI.isLollipop() ? android.R.interpolator.linear_out_slow_in
            : android.R.interpolator.accelerate_decelerate;
    // translate icon to match the launching screen then animate back into position
    searchBackContainer.setTranslationX(searchBackDistanceX);
    searchBackContainer.animate().translationX(0f).setDuration(650L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, interpolator));
    if (UI.isLollipop()) {
        // transform from search icon to back icon
        AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this,
                R.drawable.avd_search_to_back);
        searchBack.setImageDrawable(searchToBack);
        searchToBack.start();
    } else {
        searchBack.setVisibility(View.INVISIBLE);
        searchBack.setImageResource(R.drawable.ic_arrow_back_padded);
    }
    // for some reason the animation doesn't always finish (leaving a part arrow!?) so after
    // the animation set a static drawable. Also animation callbacks weren't added until API23
    // so using post delayed :(
    // TODO fix properly!!
    searchBack.postDelayed(new Runnable() {
        @Override
        public void run() {
            searchBack.setImageDrawable(
                    ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded));
        }
    }, 600);

    // fade in the other search chrome
    searchBackground.animate().alpha(1f).setDuration(300L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, backInterpolator));
    searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, backInterpolator))
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    searchView.requestFocus();
                    ImeUtils.showIme(searchView);
                }
            });

    if (UI.isLollipop()) {
        // animate in a scrim over the content behind
        scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public boolean onPreDraw() {
                scrim.getViewTreeObserver().removeOnPreDrawListener(this);
                AnimatorSet showScrim = new AnimatorSet();
                showScrim.playTogether(
                        ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX,
                                searchBackground.getBottom(), 0,
                                (float) Math.hypot(searchBackDistanceX,
                                        scrim.getHeight() - searchBackground.getBottom())),
                        ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT,
                                ContextCompat.getColor(SearchActivity.this, R.color.scrim)));
                showScrim.setDuration(400L);
                showScrim.setInterpolator(
                        AnimationUtils.loadInterpolator(SearchActivity.this, backInterpolator));
                showScrim.start();
                return false;
            }
        });
    }

    onNewIntent(getIntent());
}

From source file:com.adkdevelopment.earthquakesurvival.utils.Utilities.java

/**
 * Makes sliding from the bottom effect on elements in a RecyclerView.
 * @param context from which call is made.
 * @param viewGroup on which to perform the animation.
 *//*from ww  w.  j av a  2s .c  om*/
public static void animateViewsIn(Context context, ViewGroup viewGroup) {
    if (viewGroup != null) {
        int count = viewGroup.getChildCount();
        float offset = context.getResources().getDimensionPixelSize(R.dimen.offset_y);

        Interpolator interpolator;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            interpolator = AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in);
        } else {
            interpolator = AnimationUtils.loadInterpolator(context, android.R.interpolator.linear);
        }

        // loop over the children setting an increasing translation y but the same animation
        // duration + interpolation
        for (int i = 0; i < count; i++) {
            View view = viewGroup.getChildAt(i);
            view.setVisibility(View.VISIBLE);
            view.setTranslationY(offset);
            view.setAlpha(0.85f);
            // then animate back to natural position
            view.animate().translationY(0f).alpha(1f).setInterpolator(interpolator).setDuration(300L).start();
            // increase the offset distance for the next view
            offset *= 1.5f;
        }
    }
}