Example usage for android.animation AnimatorSet setInterpolator

List of usage examples for android.animation AnimatorSet setInterpolator

Introduction

In this page you can find the example usage for android.animation AnimatorSet setInterpolator.

Prototype

@Override
public void setInterpolator(TimeInterpolator interpolator) 

Source Link

Document

Sets the TimeInterpolator for all current #getChildAnimations() child animations of this AnimatorSet.

Usage

From source file:babbq.com.searchplace.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  ww  .j a  v a 2  s . com
                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();
    }
}

From source file:com.sysdata.widget.accordion.ExpandedViewHolder.java

@Override
public Animator onAnimateChange(List<Object> payloads, int fromLeft, int fromTop, int fromRight, int fromBottom,
        long duration) {
    if (payloads == null || payloads.isEmpty()) {
        return null;
    }/*  ww  w. ja  va 2  s.  co  m*/

    final AnimatorSet animatorSet = new AnimatorSet();
    if (arrow != null) {
        animatorSet.playTogether(
                AnimatorUtils.getBoundsAnimator(itemView, fromLeft, fromTop, fromRight, fromBottom,
                        itemView.getLeft(), itemView.getTop(), itemView.getRight(), itemView.getBottom()),
                ObjectAnimator.ofFloat(arrow, TRANSLATION_Y, 0f));
    } else {
        animatorSet.playTogether(AnimatorUtils.getBoundsAnimator(itemView, fromLeft, fromTop, fromRight,
                fromBottom, itemView.getLeft(), itemView.getTop(), itemView.getRight(), itemView.getBottom()));
    }
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            setTranslationY(0f);
            itemView.requestLayout();
        }
    });
    animatorSet.setDuration(duration);
    animatorSet.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN);

    return animatorSet;
}

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   www. j  a  va 2s .  co  m*/
}

From source file:im.ene.lab.attiq.ui.activities.SearchActivity.java

@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_search);
      ButterKnife.bind(this);
      setupSearchView();/* w  w  w .  ja v a2  s  .  co  m*/
      mAutoTransition = TransitionInflater.from(this).inflateTransition(R.transition.auto)
              .setInterpolator(LINEAR_OUT_SLOW_INT);

      mSearchResultCallback = new Callback<List<Article>>() {
          @Override
          public void onResponse(Call<List<Article>> call, Response<List<Article>> response) {
              List<Article> data = response.body();
              if (!UIUtil.isEmpty(data)) {
                  if (mRecyclerView.getVisibility() != View.VISIBLE) {
                      TransitionManager.beginDelayedTransition(mMainContainer, mAutoTransition);
                      mProgress.setVisibility(View.GONE);
                      mRecyclerView.setVisibility(View.VISIBLE);
                  }
                  mAdapter.addItems(data);
              } else {
                  TransitionManager.beginDelayedTransition(mMainContainer, mAutoTransition);
                  mProgress.setVisibility(View.GONE);
                  setNoResultsVisibility(View.VISIBLE);
              }
          }

          @Override
          public void onFailure(Call<List<Article>> call, Throwable t) {
          }
      };

      mAdapter = new ArticleListAdapter() {
          @Override
          public void loadItems(boolean isLoadingMore, int page, int pageLimit, @Nullable String query,
                  Callback<List<Article>> callback) {
              ApiClient.items(page, pageLimit, query).enqueue(callback);
          }
      };

      mOnResultItemClick = new ArticleListAdapter.OnArticleClickListener() {
          @Override
          public void onUserClick(User user) {
              startActivity(ProfileActivity.createIntent(SearchActivity.this, user.getId()));
          }

          @Override
          public void onItemContentClick(Article item) {
              startActivity(ItemDetailActivity.createIntent(SearchActivity.this, item.getId()));
          }
      };

      mAdapter.setOnItemClickListener(mOnResultItemClick);

      mRecyclerView.setAdapter(mAdapter);
      mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
      GridLayoutManager layoutManager = new GridLayoutManager(this, mColumns);
      layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
          @Override
          public int getSpanSize(int position) {
              // return mAdapter.getItemColumnSpan(position);
              return mColumns;
          }
      });
      mRecyclerView.setLayoutManager(layoutManager);
      mRecyclerView.addOnScrollListener(new EndlessScrollListener(layoutManager) {
          @Override
          protected void loadMore() {
              mHandler.removeMessages(MESSAGE_LOAD_MORE);
              mHandler.sendEmptyMessageDelayed(MESSAGE_LOAD_MORE, 200);
          }
      });

      mRecyclerView.setHasFixedSize(true);
      mRecyclerView.addOnScrollListener(mOnGridScroll);

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

      // translate icon to match the launching screen then animate back into position
      mSearchNavButtonContainer.setTranslationX(mSearchBackDistanceX);
      mSearchNavButtonContainer.animate().translationX(0f).setDuration(650L).setInterpolator(LINEAR_OUT_SLOW_INT);
      // change from search icon to back icon
      DrawerArrowDrawable searchToBack = new DrawerArrowDrawable(mSearchNavButton.getContext());
      searchToBack.setDirection(DrawerArrowDrawable.ARROW_DIRECTION_LEFT);
      searchToBack.setProgress(1.f);
      mSearchNavButton.setImageDrawable(searchToBack);

      // fade in the other search chrome
      mSearchBackground.animate().alpha(1f).setDuration(300L).setInterpolator(LINEAR_OUT_SLOW_INT);
      mSearchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L).setInterpolator(LINEAR_OUT_SLOW_INT)
              .setListener(new AnimatorListenerAdapter() {
                  @Override
                  public void onAnimationEnd(Animator animation) {
                      mSearchView.requestFocus();
                      ImeUtil.showIme(mSearchView);
                  }
              });

      // animate in a mScrim over the content behind
      mScrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
          @Override
          public boolean onPreDraw() {
              mScrim.getViewTreeObserver().removeOnPreDrawListener(this);
              AnimatorSet showScrim = new AnimatorSet();
              showScrim.playTogether(
                      ViewAnimationUtils.createCircularReveal(mScrim, mSearchIconCenterX,
                              mSearchBackground.getBottom(), 0,
                              (float) Math.hypot(mSearchBackDistanceX,
                                      mScrim.getHeight() - mSearchBackground.getBottom())),
                      AnimUtil.ofArgb(mScrim, UIUtil.BACKGROUND_COLOR, Color.TRANSPARENT,
                              ContextCompat.getColor(SearchActivity.this, R.color.scrim)));
              showScrim.setDuration(400L);
              showScrim.setInterpolator(LINEAR_OUT_SLOW_INT);
              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  a v  a 2  s  .  c o 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:io.plaidapp.ui.SearchActivity.java

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

    dataManager = new SearchDataManager(this) {
        @Override
        public void onDataLoaded(List<? extends PlaidItem> 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));
                }
                adapter.addAndResort(data);
            } else {
                TransitionManager.beginDelayedTransition(container, auto);
                progress.setVisibility(View.GONE);
                setNoResultsVisibility(View.VISIBLE);
            }
        }
    };
    adapter = new FeedAdapter(this, dataManager, PocketUtils.isPocketInstalled(this));
    results.setAdapter(adapter);
    GridLayoutManager layoutManager = new GridLayoutManager(this, columns);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return position == adapter.getDataItemCount() ? columns : 1;
        }
    });
    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:net.huannguyen.conductorexample.transition.DetailPopAnimChangeHandler.java

@NonNull
@Override//  w ww  .j  a  v  a 2s.c om
protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to,
        boolean isPush, boolean toAddedToContainer) {

    // Make sure the from view is a CountryDetailView
    if (from == null || !(from instanceof CountryDetailView))
        throw new IllegalArgumentException("The from view must be a CountryDetailView");

    if (to == null)
        throw new IllegalArgumentException("The to view must not be null");

    final CountryDetailView detailView = (CountryDetailView) from;

    AnimatorSet animatorSet = new AnimatorSet();

    // Set the to View's alpha to 0 to hide it at the beginning.
    to.setAlpha(0);

    // Scale down to hide the fab button
    PropertyValuesHolder fabScaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0);
    PropertyValuesHolder fabScaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0);
    Animator hideFabButtonAnimator = ObjectAnimator.ofPropertyValuesHolder(detailView.favouriteFab, fabScaleX,
            fabScaleY);

    // Slide up the flag
    Animator flagAnimator = ObjectAnimator.ofFloat(detailView.flagView, View.TRANSLATION_Y, 0,
            -detailView.flagView.getHeight());

    // Slide down the details
    Animator detailAnimator = ObjectAnimator.ofFloat(detailView.detailGroup, View.TRANSLATION_Y, 0,
            detailView.detailGroup.getHeight());

    // Show the new view
    Animator showToViewAnimator = ObjectAnimator.ofFloat(to, View.ALPHA, 0, 1);

    animatorSet.playTogether(hideFabButtonAnimator, flagAnimator, detailAnimator, showToViewAnimator);
    animatorSet.setDuration(300);
    animatorSet.setInterpolator(new FastOutLinearInInterpolator());

    animatorSet.start();

    return animatorSet;
}

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

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

    dataManager = new SearchDataManager(this) {
        @Override
        public void onDataLoaded(List<? extends PlaidItem> 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));
                }
                adapter.addAndResort(data);
            } else {
                TransitionManager.beginDelayedTransition(container, auto);
                progress.setVisibility(View.GONE);
                setNoResultsVisibility(View.VISIBLE);
            }
        }
    };
    adapter = new FeedAdapter(this, dataManager, 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, 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));
        }
    }, 600L);

    // 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:com.commonsware.cwac.cam2.support.CameraFragment.java

private void changeMenuIconAnimation(final FloatingActionMenu menu) {
    AnimatorSet set = new AnimatorSet();
    final ImageView v = menu.getMenuIconView();
    ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(v, "scaleX", 1.0f, 0.2f);
    ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(v, "scaleY", 1.0f, 0.2f);
    ObjectAnimator scaleInX = ObjectAnimator.ofFloat(v, "scaleX", 0.2f, 1.0f);
    ObjectAnimator scaleInY = ObjectAnimator.ofFloat(v, "scaleY", 0.2f, 1.0f);

    scaleOutX.setDuration(50);/*  w  ww  . j a  v  a2 s  .  co m*/
    scaleOutY.setDuration(50);

    scaleInX.setDuration(150);
    scaleInY.setDuration(150);
    scaleInX.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            v.setImageResource(
                    menu.isOpened() ? R.drawable.cwac_cam2_ic_close : R.drawable.cwac_cam2_ic_action_settings);
        }
    });

    set.play(scaleOutX).with(scaleOutY);
    set.play(scaleInX).with(scaleInY).after(scaleOutX);
    set.setInterpolator(new OvershootInterpolator(2));
    menu.setIconToggleAnimatorSet(set);
}

From source file:com.b44t.ui.ActionBar.BottomSheet.java

private void startOpenAnimation() {
    containerView.setVisibility(View.VISIBLE);

    if (!onCustomOpenAnimation()) {
        if (Build.VERSION.SDK_INT >= 20) {
            container.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        }//  w ww.j a  v a  2 s  .  c o m
        containerView.setTranslationY(containerView.getMeasuredHeight());
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationY", 0),
                ObjectAnimator.ofInt(backDrawable, "alpha", 51));
        animatorSet.setDuration(200);
        animatorSet.setStartDelay(20);
        animatorSet.setInterpolator(new DecelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapterProxy() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                    if (delegate != null) {
                        delegate.onOpenAnimationEnd();
                    }
                    container.setLayerType(View.LAYER_TYPE_NONE, null);
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                }
            }
        });
        animatorSet.start();
        currentSheetAnimation = animatorSet;
    }
}