Example usage for android.support.v4.view ViewPropertyAnimatorCompat start

List of usage examples for android.support.v4.view ViewPropertyAnimatorCompat start

Introduction

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

Prototype

public void start() 

Source Link

Usage

From source file:de.base.utility.animators.ScaleInAnimator.java

private void animateRemove(View view, float scale, Runnable startAction, Runnable endAction,
        @Nullable RecyclerView.ViewHolder holder) {
    ViewPropertyAnimatorCompat viewAnimator = ViewCompat.animate(view).scaleX(scale).scaleY(scale)
            .setDuration(getRemoveDuration()).setInterpolator(mInterpolator);

    if (holder != null)
        viewAnimator.setListener(new DefaultRemoveVpaListener(holder));
    if (startAction != null)
        viewAnimator.withStartAction(startAction);
    if (endAction != null)
        viewAnimator.withEndAction(endAction);

    viewAnimator.start();
}

From source file:com.twotoasters.jazzylistview.JazzyHelper.java

private void doJazzinessImpl(View item, int position, int scrollDirection) {
    ViewPropertyAnimatorCompat animator = ViewCompat.animate(item).setDuration(DURATION)
            .setInterpolator(new AccelerateDecelerateInterpolator());

    scrollDirection = scrollDirection > 0 ? 1 : -1;
    mTransitionEffect.initView(item, position, scrollDirection);
    mTransitionEffect.setupAnimation(item, position, scrollDirection, animator);
    animator.start();
}

From source file:android.support.v7.widget.ToolbarWidgetWrapper.java

@Override
public void animateToVisibility(int visibility) {
    ViewPropertyAnimatorCompat anim = setupAnimatorToVisibility(visibility, DEFAULT_FADE_DURATION_MS);
    if (anim != null) {
        anim.start();
    }/*from www . jav a2 s  .co  m*/
}

From source file:bottombar.BottomBarTab.java

private void animateTitle(float finalScale, float finalAlpha) {
    if (type == Type.TABLET) {
        return;//from  w ww  .j a  v  a  2  s.  c o m
    }

    ViewPropertyAnimatorCompat titleAnimator = ViewCompat.animate(titleView).setDuration(ANIMATION_DURATION)
            .scaleX(finalScale).scaleY(finalScale);
    titleAnimator.alpha(finalAlpha);
    titleAnimator.start();
}

From source file:android.support.v7.internal.widget.ScrollingTabContainerView.java

public void animateToVisibility(int visibility) {
    if (mVisibilityAnim != null) {
        mVisibilityAnim.cancel();//  www  .  j av a 2 s.com
    }
    if (visibility == VISIBLE) {
        if (getVisibility() != VISIBLE) {
            ViewCompat.setAlpha(this, 0f);
        }

        ViewPropertyAnimatorCompat anim = ViewCompat.animate(this).alpha(1f);
        anim.setDuration(FADE_DURATION);

        anim.setInterpolator(sAlphaInterpolator);
        anim.setListener(mVisAnimListener.withFinalVisibility(anim, visibility));
        anim.start();
    } else {
        ViewPropertyAnimatorCompat anim = ViewCompat.animate(this).alpha(0f);
        anim.setDuration(FADE_DURATION);

        anim.setInterpolator(sAlphaInterpolator);
        anim.setListener(mVisAnimListener.withFinalVisibility(anim, visibility));
        anim.start();
    }
}

From source file:com.roughike.bottombar.BottomBarTab.java

private void animateTitle(int padding, float scale, float alpha) {
    if (type == Type.TABLET && isTitleless) {
        return;// ww w.ja va2 s  .  c  o m
    }

    setTopPaddingAnimated(iconView.getPaddingTop(), padding);

    ViewPropertyAnimatorCompat titleAnimator = ViewCompat.animate(titleView).setDuration(ANIMATION_DURATION)
            .scaleX(scale).scaleY(scale);
    titleAnimator.alpha(alpha);
    titleAnimator.start();
}

From source file:android.support.v7.internal.widget.AbsActionBarView.java

public void animateToVisibility(int visibility) {
    if (mVisibilityAnim != null) {
        mVisibilityAnim.cancel();/*from ww w . j  a  v  a  2  s.c  o  m*/
    }
    if (visibility == VISIBLE) {
        if (getVisibility() != VISIBLE) {
            ViewCompat.setAlpha(this, 0f);
            if (mSplitView != null && mMenuView != null) {
                ViewCompat.setAlpha(mMenuView, 0f);
            }
        }
        ViewPropertyAnimatorCompat anim = ViewCompat.animate(this).alpha(1f);
        anim.setDuration(FADE_DURATION);
        anim.setInterpolator(sAlphaInterpolator);
        if (mSplitView != null && mMenuView != null) {
            ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet();
            ViewPropertyAnimatorCompat splitAnim = ViewCompat.animate(mMenuView).alpha(1f);
            splitAnim.setDuration(FADE_DURATION);
            set.setListener(mVisAnimListener.withFinalVisibility(anim, visibility));
            set.play(anim).play(splitAnim);
            set.start();
        } else {
            anim.setListener(mVisAnimListener.withFinalVisibility(anim, visibility));
            anim.start();
        }
    } else {
        ViewPropertyAnimatorCompat anim = ViewCompat.animate(this).alpha(0f);
        anim.setDuration(FADE_DURATION);
        anim.setInterpolator(sAlphaInterpolator);
        if (mSplitView != null && mMenuView != null) {
            ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet();
            ViewPropertyAnimatorCompat splitAnim = ViewCompat.animate(mMenuView).alpha(0f);
            splitAnim.setDuration(FADE_DURATION);
            set.setListener(mVisAnimListener.withFinalVisibility(anim, visibility));
            set.play(anim).play(splitAnim);
            set.start();
        } else {
            anim.setListener(mVisAnimListener.withFinalVisibility(anim, visibility));
            anim.start();
        }
    }
}

From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java

private void showSuggestions(final boolean show) {
    if (show == suggestionsShown())
        return;/* w  w  w  .  jav a  2  s . c  om*/

    suggestionsShown = show;

    int childCount = recyclerView.getChildCount();
    int translation = 0;

    final Runnable endAction = () -> {
        if (show) {
            updateDivider();
        } else {
            showDivider(false);
            recyclerView.setVisibility(View.INVISIBLE);
            recyclerView.setTranslationY(-recyclerView.getHeight());
        }
    };

    if (show) {
        updateDivider();
        recyclerView.setVisibility(VISIBLE);
        if (recyclerView.getTranslationY() == 0)
            recyclerView.setTranslationY(-recyclerView.getHeight());
    } else if (childCount > 0) {
        translation = -recyclerView.getChildAt(childCount - 1).getBottom();
    } else {
        showDivider(false);
    }

    ViewPropertyAnimatorCompat listAnim = ViewCompat.animate(recyclerView).translationY(translation)
            .setDuration(show ? DEFAULT_DURATION_ENTER : DEFAULT_DURATION_EXIT)
            .setInterpolator(show ? DECELERATE : ACCELERATE).withLayer().withEndAction(endAction);

    if (show || childCount > 0) {
        listAnim.start();
    } else {
        endAction.run();
    }
}

From source file:vc908.stickerfactory.ui.advancedrecyclerview.draggable.BaseDraggableItemDecorator.java

protected void moveToDefaultPosition(View targetView, boolean animate) {
    final int curTranslationY = (int) (ViewCompat.getTranslationY(targetView));
    final int halfItemHeight = targetView.getHeight() / 2;
    final float translationProportion = (halfItemHeight > 0)
            ? Math.abs((float) curTranslationY / halfItemHeight)
            : 0;/*  w ww  .jav  a2  s .  co m*/
    final float t = 1.0f - Math.min(translationProportion, 1.0f);
    final int animDuration = (int) (mReturnToDefaultPositionDuration * (1.0f - (t * t)) + 0.5f);

    if (supportsViewPropertyAnimation() && animate
            && (animDuration > RETURN_TO_DEFAULT_POS_ANIMATE_THRESHOLD_MSEC)
            && (Math.abs(curTranslationY) > mReturnToDefaultPositionAnimateThreshold)) {
        final ViewPropertyAnimatorCompat animator = ViewCompat.animate(targetView);
        animator.cancel();
        animator.setDuration(animDuration);
        animator.setInterpolator(mReturnToDefaultPositionInterpolator);
        animator.translationY(0.0f);
        animator.setListener(new ViewPropertyAnimatorListener() {
            @Override
            public void onAnimationStart(View view) {
            }

            @Override
            public void onAnimationEnd(View view) {
                animator.setListener(null);
                ViewCompat.setTranslationY(view, 0);

                // invalidate explicitly to refresh other decorations
                if (view.getParent() instanceof RecyclerView) {
                    ViewCompat.postInvalidateOnAnimation((RecyclerView) view.getParent());
                }
            }

            @Override
            public void onAnimationCancel(View view) {
            }
        });
        animator.start();
    } else {
        ViewCompat.setTranslationY(targetView, 0);
    }
}

From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.draggable.BaseDraggableItemDecorator.java

protected void moveToDefaultPosition(View targetView, boolean animate) {
    final int curTranslationX = (int) (ViewCompat.getTranslationX(targetView));
    final int curTranslationY = (int) (ViewCompat.getTranslationY(targetView));
    final int halfItemWidth = targetView.getWidth() / 2;
    final int halfItemHeight = targetView.getHeight() / 2;
    final float translationProportionX = (halfItemWidth > 0) ? Math.abs((float) curTranslationX / halfItemWidth)
            : 0;//ww w. j  a v  a2s .com
    final float translationProportionY = (halfItemHeight > 0)
            ? Math.abs((float) curTranslationY / halfItemHeight)
            : 0;
    final float tx = 1.0f - Math.min(translationProportionX, 1.0f);
    final float ty = 1.0f - Math.min(translationProportionY, 1.0f);
    final int animDurationX = (int) (mReturnToDefaultPositionDuration * (1.0f - (tx * tx)) + 0.5f);
    final int animDurationY = (int) (mReturnToDefaultPositionDuration * (1.0f - (ty * ty)) + 0.5f);
    final int animDuration = Math.max(animDurationX, animDurationY);
    final int maxAbsTranslation = Math.max(Math.abs(curTranslationX), Math.abs(curTranslationY));

    if (supportsViewPropertyAnimation() && animate
            && (animDuration > RETURN_TO_DEFAULT_POS_ANIMATE_THRESHOLD_MSEC)
            && (maxAbsTranslation > mReturnToDefaultPositionAnimateThreshold)) {
        final ViewPropertyAnimatorCompat animator = ViewCompat.animate(targetView);
        animator.cancel();
        animator.setDuration(animDuration);
        animator.setInterpolator(mReturnToDefaultPositionInterpolator);
        animator.translationX(0.0f);
        animator.translationY(0.0f);
        animator.setListener(new ViewPropertyAnimatorListener() {
            @Override
            public void onAnimationStart(View view) {
            }

            @Override
            public void onAnimationEnd(View view) {
                animator.setListener(null);
                ViewCompat.setTranslationX(view, 0);
                ViewCompat.setTranslationY(view, 0);

                // invalidate explicitly to refresh other decorations
                if (view.getParent() instanceof RecyclerView) {
                    ViewCompat.postInvalidateOnAnimation((RecyclerView) view.getParent());
                }
            }

            @Override
            public void onAnimationCancel(View view) {
            }
        });
        animator.start();
    } else {
        ViewCompat.setTranslationX(targetView, 0);
        ViewCompat.setTranslationY(targetView, 0);
    }
}