Example usage for android.animation Animator setInterpolator

List of usage examples for android.animation Animator setInterpolator

Introduction

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

Prototype

public abstract void setInterpolator(TimeInterpolator value);

Source Link

Document

The time interpolator used in calculating the elapsed fraction of the animation.

Usage

From source file:com.hannesdorfmann.search.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  www  .ja v  a2s .  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();
  }

From source file:com.androidinspain.deskclock.timer.TimerFragment.java

/**
 * @param timerToRemove the timer to be removed during the animation
 *//*  www  .j a v  a 2  s. c o  m*/
private void animateTimerRemove(final Timer timerToRemove) {
    final long duration = UiDataModel.getUiDataModel().getShortAnimationDuration();

    final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0);
    fadeOut.setDuration(duration);
    fadeOut.setInterpolator(new DecelerateInterpolator());
    fadeOut.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            DataModel.getDataModel().removeTimer(timerToRemove);
            Events.sendTimerEvent(com.androidinspain.deskclock.R.string.action_delete,
                    com.androidinspain.deskclock.R.string.label_deskclock);
        }
    });

    final Animator fadeIn = ObjectAnimator.ofFloat(mViewPager, ALPHA, 0, 1);
    fadeIn.setDuration(duration);
    fadeIn.setInterpolator(new AccelerateInterpolator());

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(fadeOut).before(fadeIn);
    animatorSet.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  w  w w. ja  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();
}

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 ww  w .  ja  v a  2 s .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.ui.HomeActivity.java

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

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//from   w  ww.  j  av  a  2  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:android.support.v17.leanback.app.OnboardingSupportFragment.java

private Animator createAnimator(View view, boolean fadeIn, int slideDirection, long startDelay) {
    boolean isLtr = getView().getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
    boolean slideRight = (isLtr && slideDirection == Gravity.END) || (!isLtr && slideDirection == Gravity.START)
            || slideDirection == Gravity.RIGHT;
    Animator fadeAnimator;
    Animator slideAnimator;/*from w  ww .  j  a  v a2s  . c  o m*/
    if (fadeIn) {
        fadeAnimator = ObjectAnimator.ofFloat(view, View.ALPHA, 0.0f, 1.0f);
        slideAnimator = ObjectAnimator.ofFloat(view, View.TRANSLATION_X,
                slideRight ? sSlideDistance : -sSlideDistance, 0);
        fadeAnimator.setInterpolator(HEADER_APPEAR_INTERPOLATOR);
        slideAnimator.setInterpolator(HEADER_APPEAR_INTERPOLATOR);
    } else {
        fadeAnimator = ObjectAnimator.ofFloat(view, View.ALPHA, 1.0f, 0.0f);
        slideAnimator = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, 0,
                slideRight ? sSlideDistance : -sSlideDistance);
        fadeAnimator.setInterpolator(HEADER_DISAPPEAR_INTERPOLATOR);
        slideAnimator.setInterpolator(HEADER_DISAPPEAR_INTERPOLATOR);
    }
    fadeAnimator.setDuration(HEADER_ANIMATION_DURATION_MS);
    fadeAnimator.setTarget(view);
    slideAnimator.setDuration(HEADER_ANIMATION_DURATION_MS);
    slideAnimator.setTarget(view);
    AnimatorSet animator = new AnimatorSet();
    animator.playTogether(fadeAnimator, slideAnimator);
    if (startDelay > 0) {
        animator.setStartDelay(startDelay);
    }
    return animator;
}

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

private void expandImageAndFinish() {
    if (imageView.getOffset() != 0f) {
        Animator expandImage = ObjectAnimator.ofFloat(imageView, ParallaxScrimageView.OFFSET, 0f);
        expandImage.setDuration(80);/* w w  w  .  j a  v a  2  s .  com*/
        expandImage.setInterpolator(
                AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in));
        expandImage.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                finishAfterTransition();
            }
        });
        expandImage.start();
    } else {
        finishAfterTransition();
    }
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

private Animator getRevealAnimator(View source, int revealColor) {
    final ViewGroup containerView = (ViewGroup) source.getRootView().findViewById(android.R.id.content);

    final Rect sourceBounds = new Rect(0, 0, source.getHeight(), source.getWidth());
    containerView.offsetDescendantRectToMyCoords(source, sourceBounds);

    final int centerX = sourceBounds.centerX();
    final int centerY = sourceBounds.centerY();

    final int xMax = Math.max(centerX, containerView.getWidth() - centerX);
    final int yMax = Math.max(centerY, containerView.getHeight() - centerY);

    final float startRadius = Math.max(sourceBounds.width(), sourceBounds.height()) / 2.0f;
    final float endRadius = (float) Math.sqrt(xMax * xMax + yMax * yMax);

    final CircleView revealView = new CircleView(source.getContext()).setCenterX(centerX).setCenterY(centerY)
            .setFillColor(revealColor);//  w w  w  . ja v a 2s.  c  o  m
    containerView.addView(revealView);

    final Animator revealAnimator = ObjectAnimator.ofFloat(revealView, CircleView.RADIUS, startRadius,
            endRadius);
    revealAnimator.setInterpolator(PathInterpolatorCompat.create(0.0f, 0.0f, 0.2f, 1.0f));

    final ValueAnimator fadeAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    fadeAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            containerView.removeView(revealView);
        }
    });

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(TimerFragment.ANIMATION_TIME_MILLIS);
    animatorSet.playSequentially(revealAnimator, fadeAnimator);

    return revealAnimator;
}

From source file:com.taobao.weex.dom.action.AnimationAction.java

private void startAnimation(@NonNull WXSDKInstance instance, @Nullable WXComponent component) {
    if (component != null) {
        if (component.getHostView() == null) {
            WXAnimationModule.AnimationHolder holder = new WXAnimationModule.AnimationHolder(mAnimationBean,
                    callback);/*from   ww w  .j ava2 s .  c o m*/
            component.postAnimation(holder);
        } else {
            try {
                Animator animator = createAnimator(component.getHostView(),
                        instance.getInstanceViewPortWidth());
                if (animator != null) {
                    Animator.AnimatorListener animatorCallback = createAnimatorListener(instance, callback);
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2
                            && component.isLayerTypeEnabled()) {
                        component.getHostView().setLayerType(View.LAYER_TYPE_HARDWARE, null);
                    }
                    Interpolator interpolator = createTimeInterpolator();
                    if (animatorCallback != null) {
                        animator.addListener(animatorCallback);
                    }
                    if (interpolator != null) {
                        animator.setInterpolator(interpolator);
                    }
                    animator.setDuration(mAnimationBean.duration);
                    animator.start();
                }
            } catch (RuntimeException e) {
                WXLogUtils.e(TAG, WXLogUtils.getStackTrace(e));
            }
        }
    }
}