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: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   ww w.  ja v a2 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:android.transitions.everywhere.Transition.java

/**
 * Perform inflation from XML and apply a class-specific base style from a
 * theme attribute or style resource. This constructor of Transition allows
 * subclasses to use their own base style when they are inflating.
 *
 * @param context The Context the transition is running in, through which it can
 *        access the current theme, resources, etc.
 * @param attrs The attributes of the XML tag that is inflating the transition.
 *///from   w ww.  ja v  a2  s  . c om
public Transition(Context context, AttributeSet attrs) {

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Transition);
    long duration = a.getInt(R.styleable.Transition_duration, -1);
    if (duration >= 0) {
        setDuration(duration);
    } else {
        duration = a.getInt(R.styleable.Transition_android_duration, -1);
        if (duration >= 0) {
            setDuration(duration);
        }
    }
    long startDelay = a.getInt(R.styleable.Transition_startDelay, -1);
    if (startDelay > 0) {
        setStartDelay(startDelay);
    }
    int resID = a.getResourceId(R.styleable.Transition_interpolator, 0);
    if (resID > 0) {
        setInterpolator(AnimationUtils.loadInterpolator(context, resID));
    } else {
        resID = a.getResourceId(R.styleable.Transition_android_interpolator, 0);
        if (resID > 0) {
            setInterpolator(AnimationUtils.loadInterpolator(context, resID));
        }
    }
    String matchOrder = a.getString(R.styleable.Transition_matchOrder);
    if (matchOrder != null) {
        setMatchOrder(parseMatchOrder(matchOrder));
    }
    a.recycle();
}

From source file:com.android.systemui.statusbar.phone.NotificationPanelView.java

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mHeader = (StatusBarHeaderView) findViewById(R.id.header);
    mHeader.setOnClickListener(this);
    mKeyguardStatusView = (KeyguardStatusView) findViewById(R.id.keyguard_status_view);
    mNotificationContainerParent = (NotificationsQuickSettingsContainer) findViewById(
            R.id.notification_container_parent);
    mKeyguardStatusBar = (KeyguardStatusBarView) mNotificationContainerParent
            .findViewById(R.id.keyguard_header);
    mClockView = (TextView) findViewById(R.id.clock_view);

    mNotificationsViewPager = (NotificationsViewPager) mNotificationContainerParent
            .findViewById(R.id.notification_viewpager);
    NotificationPagerAdapter mAdapter = (NotificationPagerAdapter) mNotificationsViewPager.getAdapter();
    mIndicator = (CirclePageIndicator) findViewById(R.id.qucii_indicator);
    mArrow = findViewById(R.id.qucii_arrow);
    mArrowLayout = findViewById(R.id.qucii_arrow_layout);
    mIndicator.setViewPager(mNotificationsViewPager);
    mIndicator.setOnPageChangeListener(this);
    mNotificationsViewPager.setPanelView(this);
    List<View> views = mAdapter.getViews();
    mNotificationStackScroller = (NotificationStackScrollLayout) views.get(0);
    mScrollView = (ObservableScrollView) views.get(1);
    mScrollView.setNotificationPanelView(this);
    mQsContainer = (QSContainer) mScrollView.findViewById(R.id.quick_settings_container);
    mQsContainer_Qucii = (QSContainer) mScrollView.findViewById(R.id.qucii_quick_settings_container);

    mQsPanel = (QSPanel) mScrollView.findViewById(R.id.quick_settings_panel);
    mQsPanel_Qucii = (QSPanel) mScrollView.findViewById(R.id.qucii_quick_settings_panel);
    mQsPanel_Qucii.setExpanded(true);// ww w .  j  a v a 2  s . c  o  m
    mQsPanel_Qucii.setIndicatorListener(this);// added by yangfan 
    mScrollView.setListener(this);
    mScrollView.setFocusable(false);
    mReserveNotificationSpace = mScrollView.findViewById(R.id.reserve_notification_space);
    mNotificationStackScroller.setOnHeightChangedListener(this);
    mNotificationStackScroller.setOverscrollTopChangedListener(this);
    mNotificationStackScroller.setOnEmptySpaceClickListener(this);
    mNotificationStackScroller.setScrollView(mScrollView);
    mNotificationStackScroller.setNotificationPanelView(this);
    mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(),
            android.R.interpolator.fast_out_slow_in);
    mFastOutLinearInterpolator = AnimationUtils.loadInterpolator(getContext(),
            android.R.interpolator.fast_out_linear_in);
    mDozeAnimationInterpolator = AnimationUtils.loadInterpolator(getContext(),
            android.R.interpolator.linear_out_slow_in);
    mKeyguardBottomArea = (KeyguardBottomAreaView) findViewById(R.id.keyguard_bottom_area);
    mQsNavbarScrim = findViewById(R.id.qs_navbar_scrim);
    mAfforanceHelper = new KeyguardAffordanceHelper(this, getContext());
    mLastOrientation = getResources().getConfiguration().orientation;

    // recompute internal state when qspanel height changes
    mQsContainer.addOnLayoutChangeListener(new OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop,
                int oldRight, int oldBottom) {
            final int height = bottom - top;
            final int oldHeight = oldBottom - oldTop;
            if (height != oldHeight) {
                onScrollChanged();
            }
        }
    });

}

From source file:org.huxizhijian.hhcomicviewer.ui.entry.ComicDetailsActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setMotion() {
    // Activity Shared Element?
    //ArcMotion//w w w.j a  v a  2  s  .c om
    ArcMotion arcMotion = new ArcMotion();
    arcMotion.setMinimumHorizontalAngle(50f);
    arcMotion.setMinimumVerticalAngle(50f);
    //?
    Interpolator interpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in);
    //ChangeBounds
    CustomChangeBounds changeBounds = new CustomChangeBounds();
    changeBounds.setPathMotion(arcMotion);
    changeBounds.setInterpolator(interpolator);
    changeBounds.addTarget(mBinding.comicThumbnailComicDetails);
    //??Activity
    getWindow().setSharedElementEnterTransition(changeBounds);
    getWindow().setSharedElementReturnTransition(changeBounds);
}

From source file:pl.motyczko.scrollheader.CarouselContainer.java

/**
 * Restore the Y position of this view to the last manually requested value.
 * This can be done after the parent has been re-laid out again, where this
 * view's position could have been lost if the view laid outside its
 * parent's bounds./*from   w  w w  .j a v a  2 s  . c  o m*/
 * 
 * @param duration The duration of the animation
 * @param tabIndex The index to restore
 */
public void restoreYCoordinate(int duration, int tabIndex) {
    final float storedYCoordinate = getStoredYCoordinateForTab(tabIndex);

    final Interpolator interpolator = AnimationUtils.loadInterpolator(getContext(),
            android.R.anim.accelerate_decelerate_interpolator);

    final ObjectAnimator animator = ObjectAnimator.ofFloat(this, "y", storedYCoordinate);
    animator.addListener(mTabCarouselAnimatorListener);
    animator.setInterpolator(interpolator);
    animator.setDuration(duration);
    animator.start();
}

From source file:com.hannesdorfmann.home.HomeActivity.java

private void showFab() {
    fab.setAlpha(0f);//from  w w w.j  a v  a2 s .  com
    fab.setScaleX(0f);
    fab.setScaleY(0f);
    fab.setTranslationY(fab.getHeight() / 2);
    fab.animate().alpha(1f).scaleX(1f).scaleY(1f).translationY(0f).setDuration(300L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in))
            .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 w  w.j av a2s.com
        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.brandao.tictactoe.board.BoardFragment.java

public void animateOut(final ImageView image, final int index) {
    Animation zoomOutOut = AnimationUtils.loadAnimation(getActivity(), R.anim.zoom_out);
    zoomOutOut.setInterpolator(/*from   w w  w .jav a2  s .c o m*/
            AnimationUtils.loadInterpolator(getActivity(), android.R.anim.anticipate_interpolator));
    zoomOutOut.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationEnd(Animation animation) {
            mAnimating = false;
            image.setBackgroundResource(R.drawable.transparent_image);
            if (index == 8) {
                initFirstTurn();
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationStart(Animation animation) {
            mAnimating = true;
        }
    });

    image.startAnimation(zoomOutOut);
}

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

@OnClick(R.id.results_scrim)
protected void hideSaveConfimation() {
    if (confirmSaveContainer.getVisibility() == View.VISIBLE) {
        // contract the bubble & hide the scrim
        AnimatorSet hideConfirmation = new AnimatorSet();
        hideConfirmation.playTogether(//w  w  w .ja  v  a 2  s .  co m
                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.hannesdorfmann.search.SearchActivity.java

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