Example usage for android.support.v4.view ViewPropertyAnimatorUpdateListener ViewPropertyAnimatorUpdateListener

List of usage examples for android.support.v4.view ViewPropertyAnimatorUpdateListener ViewPropertyAnimatorUpdateListener

Introduction

In this page you can find the example usage for android.support.v4.view ViewPropertyAnimatorUpdateListener ViewPropertyAnimatorUpdateListener.

Prototype

ViewPropertyAnimatorUpdateListener

Source Link

Usage

From source file:com.luseen.luseenbottomnavigation.BottomNavigation.behavior.BottomNavigationBehavior.java

private void ensureOrCancelAnimator(final CoordinatorLayout coordinatorLayout, final V child) {
    if (mOffsetValueAnimator == null) {
        mOffsetValueAnimator = ViewCompat.animate(child);
        mOffsetValueAnimator.setDuration(
                coordinatorLayout.getResources().getInteger(android.R.integer.config_shortAnimTime));
        mOffsetValueAnimator.setInterpolator(INTERPOLATOR);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            mOffsetValueAnimator.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
                @Override//from  w  w w. j  a va  2 s.c o m
                public void onAnimationUpdate(View view) {
                    if (null != fabDependentView) {
                        fabDependentView.onDependentViewChanged(coordinatorLayout, child);
                    }
                    if (null != snackbarDependentView) {
                        snackbarDependentView.onDependentViewChanged(coordinatorLayout, child);
                    }

                }
            });
        } else {
            updateDependentViewsRunnable.setViews(coordinatorLayout, child);
            mOffsetValueAnimator.setListener(new ViewPropertyAnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(View view) {
                    handler.postDelayed(updateDependentViewsRunnable, 16);
                }

                @Override
                public void onAnimationEnd(View view) {
                    handler.removeCallbacks(updateDependentViewsRunnable);
                }

                @Override
                public void onAnimationCancel(View view) {
                    handler.removeCallbacks(updateDependentViewsRunnable);
                }
            });
        }
    } else {
        mOffsetValueAnimator.cancel();
    }
}

From source file:im.ene.ribbon.BottomNavigationBehavior.java

private void ensureOrCancelAnimator(final CoordinatorLayout coordinatorLayout,
        final BottomNavigationView child) {
    if (animator == null) {
        animator = ViewCompat.animate(child);
        animator.setDuration(animationDuration);
        animator.setInterpolator(INTERPOLATOR);
        animator.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
            @Override//from   w  ww . ja va2s.c  o m
            public void onAnimationUpdate(final View view) {
                if (null != fabDependentView) {
                    fabDependentView.onDependentViewChanged(coordinatorLayout, child);
                }
                if (null != snackbarDependentView) {
                    snackbarDependentView.onDependentViewChanged(coordinatorLayout, child);
                }
            }
        });
    } else {
        animator.cancel();
    }
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

private boolean updateSuggestionsSectionHeight(List<? extends SearchSuggestion> newSearchSuggestions,
        boolean withAnim) {

    final int cardTopBottomShadowPadding = Util.dpToPx(CARD_VIEW_CORNERS_AND_TOP_BOTTOM_SHADOW_HEIGHT);
    final int cardRadiusSize = Util.dpToPx(CARD_VIEW_TOP_BOTTOM_SHADOW_HEIGHT);

    int visibleSuggestionHeight = calculateSuggestionItemsHeight(newSearchSuggestions,
            mSuggestionListContainer.getHeight());
    int diff = mSuggestionListContainer.getHeight() - visibleSuggestionHeight;
    int addedTranslationYForShadowOffsets = (diff <= cardTopBottomShadowPadding)
            ? -(cardTopBottomShadowPadding - diff)
            : diff < (mSuggestionListContainer.getHeight() - cardTopBottomShadowPadding) ? cardRadiusSize : 0;
    final float newTranslationY = -mSuggestionListContainer.getHeight() + visibleSuggestionHeight
            + addedTranslationYForShadowOffsets;

    //todo go over
    final float fullyInvisibleTranslationY = -mSuggestionListContainer.getHeight() + cardRadiusSize;

    ViewCompat.animate(mSuggestionListContainer).cancel();
    if (withAnim) {
        ViewCompat.animate(mSuggestionListContainer).setInterpolator(SUGGEST_ITEM_ADD_ANIM_INTERPOLATOR)
                .setDuration(mSuggestionSectionAnimDuration).translationY(newTranslationY)
                .setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
                    @Override/*from   ww  w. j  a  va 2 s  .  c  om*/
                    public void onAnimationUpdate(View view) {

                        if (mOnSuggestionsListHeightChanged != null) {
                            float newSuggestionsHeight = Math
                                    .abs(view.getTranslationY() - fullyInvisibleTranslationY);
                            mOnSuggestionsListHeightChanged
                                    .onSuggestionsListHeightChanged(newSuggestionsHeight);
                        }
                    }
                }).setListener(new ViewPropertyAnimatorListenerAdapter() {
                    @Override
                    public void onAnimationCancel(View view) {
                        mSuggestionListContainer.setTranslationY(newTranslationY);
                    }
                }).start();
    } else {
        mSuggestionListContainer.setTranslationY(newTranslationY);
        if (mOnSuggestionsListHeightChanged != null) {
            float newSuggestionsHeight = Math
                    .abs(mSuggestionListContainer.getTranslationY() - fullyInvisibleTranslationY);
            mOnSuggestionsListHeightChanged.onSuggestionsListHeightChanged(newSuggestionsHeight);
        }
    }

    return mSuggestionListContainer.getHeight() == visibleSuggestionHeight;
}