Search in sources :

Example 41 with ViewPropertyAnimatorCompat

use of android.support.v4.view.ViewPropertyAnimatorCompat in project Lightning-Browser by anthonycr.

the class VerticalItemAnimator method animateAddImpl.

private void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);
    animation.alpha(1).translationX(0).setDuration(getAddDuration()).setInterpolator(new BezierDecelerateInterpolator()).setListener(new VpaListenerAdapter() {

        @Override
        public void onAnimationStart(View view) {
            dispatchAddStarting(holder);
        }

        @Override
        public void onAnimationCancel(View view) {
            ViewCompat.setAlpha(view, 1);
            ViewCompat.setTranslationX(view, 0);
        }

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            dispatchAddFinished(holder);
            mAddAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}
Also used : BezierDecelerateInterpolator(acr.browser.lightning.interpolator.BezierDecelerateInterpolator) ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 42 with ViewPropertyAnimatorCompat

use of android.support.v4.view.ViewPropertyAnimatorCompat in project android-advancedrecyclerview by h6ah4i.

the class BaseDraggableItemDecorator method moveToDefaultPosition.

protected void moveToDefaultPosition(View targetView, float initialScaleX, float initialScaleY, float initialRotation, float initialAlpha, boolean animate) {
    final float initialTranslationZ = ViewCompat.getTranslationZ(targetView);
    final float durationFactor = determineMoveToDefaultPositionAnimationDurationFactor(targetView, initialScaleX, initialScaleY, initialRotation, initialAlpha);
    final int animDuration = (int) (mReturnToDefaultPositionDuration * durationFactor);
    if (animate && (animDuration > RETURN_TO_DEFAULT_POS_ANIMATE_THRESHOLD_MSEC)) {
        ViewPropertyAnimatorCompat animator = ViewCompat.animate(targetView);
        targetView.setScaleX(initialScaleX);
        targetView.setScaleY(initialScaleY);
        targetView.setRotation(initialRotation);
        targetView.setAlpha(initialAlpha);
        // to render on top of other items
        ViewCompat.setTranslationZ(targetView, initialTranslationZ + 1);
        animator.cancel();
        animator.setDuration(animDuration);
        animator.setInterpolator(mReturnToDefaultPositionInterpolator);
        animator.translationX(0.0f);
        animator.translationY(0.0f);
        animator.translationZ(initialTranslationZ);
        animator.alpha(1.0f);
        animator.rotation(0);
        animator.scaleX(1.0f);
        animator.scaleY(1.0f);
        animator.setListener(new ViewPropertyAnimatorListener() {

            @Override
            public void onAnimationStart(View view) {
            }

            @Override
            public void onAnimationEnd(View view) {
                ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);
                animator.setListener(null);
                resetDraggingItemViewEffects(view, initialTranslationZ);
                // 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 {
        resetDraggingItemViewEffects(targetView, initialTranslationZ);
    }
}
Also used : ViewPropertyAnimatorListener(android.support.v4.view.ViewPropertyAnimatorListener) ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 43 with ViewPropertyAnimatorCompat

use of android.support.v4.view.ViewPropertyAnimatorCompat in project TeamCityApp by vase4kin.

the class LoginViewImpl method animate.

/**
 * {@inheritDoc}
 */
@Override
public void animate() {
    ViewCompat.animate(mLogoImageView).translationY(mActivity.getResources().getInteger(R.integer.logo_move)).setStartDelay(STARTUP_DELAY).setDuration(ANIM_ITEM_DURATION).setInterpolator(new DecelerateInterpolator(1.2f)).start();
    for (int i = 0; i < mContainer.getChildCount(); i++) {
        View v = mContainer.getChildAt(i);
        ViewPropertyAnimatorCompat viewAnimator = ViewCompat.animate(v).translationY(0).alpha(1).setStartDelay((ITEM_DELAY * i) + 500).setDuration(1000);
        viewAnimator.setInterpolator(new DecelerateInterpolator()).start();
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) ImageView(android.widget.ImageView) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View)

Example 44 with ViewPropertyAnimatorCompat

use of android.support.v4.view.ViewPropertyAnimatorCompat in project FloatingSearchView by renaudcerrato.

the class BaseItemAnimator method animateChangeImpl.

private void animateChangeImpl(final ChangeInfo changeInfo) {
    final ViewHolder holder = changeInfo.oldHolder;
    final View view = holder == null ? null : holder.itemView;
    final ViewHolder newHolder = changeInfo.newHolder;
    final View newView = newHolder != null ? newHolder.itemView : null;
    if (view != null) {
        final ViewPropertyAnimatorCompat oldViewAnim = ViewCompat.animate(view).setDuration(getChangeDuration());
        mChangeAnimations.add(changeInfo.oldHolder);
        oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
        oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
        oldViewAnim.alpha(0).setListener(new VpaListenerAdapter() {

            @Override
            public void onAnimationStart(View view) {
                dispatchChangeStarting(changeInfo.oldHolder, true);
            }

            @Override
            public void onAnimationEnd(View view) {
                oldViewAnim.setListener(null);
                ViewCompat.setAlpha(view, 1);
                ViewCompat.setTranslationX(view, 0);
                ViewCompat.setTranslationY(view, 0);
                dispatchChangeFinished(changeInfo.oldHolder, true);
                mChangeAnimations.remove(changeInfo.oldHolder);
                dispatchFinishedWhenDone();
            }
        }).start();
    }
    if (newView != null) {
        final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newView);
        mChangeAnimations.add(changeInfo.newHolder);
        newViewAnimation.translationX(0).translationY(0).setDuration(getChangeDuration()).alpha(1).setListener(new VpaListenerAdapter() {

            @Override
            public void onAnimationStart(View view) {
                dispatchChangeStarting(changeInfo.newHolder, false);
            }

            @Override
            public void onAnimationEnd(View view) {
                newViewAnimation.setListener(null);
                ViewCompat.setAlpha(newView, 1);
                ViewCompat.setTranslationX(newView, 0);
                ViewCompat.setTranslationY(newView, 0);
                dispatchChangeFinished(changeInfo.newHolder, false);
                mChangeAnimations.remove(changeInfo.newHolder);
                dispatchFinishedWhenDone();
            }
        }).start();
    }
}
Also used : ViewHolder(android.support.v7.widget.RecyclerView.ViewHolder) ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 45 with ViewPropertyAnimatorCompat

use of android.support.v4.view.ViewPropertyAnimatorCompat in project FloatingSearchView by renaudcerrato.

the class FloatingSearchView method showSuggestions.

private void showSuggestions(final boolean show) {
    if (show == suggestionsShown())
        return;
    mSuggestionsShown = show;
    int childCount = mRecyclerView.getChildCount();
    int translation = 0;
    final Runnable endAction = new Runnable() {

        @Override
        public void run() {
            if (show)
                updateDivider();
            else {
                showDivider(false);
                mRecyclerView.setVisibility(View.INVISIBLE);
                mRecyclerView.setTranslationY(-mRecyclerView.getHeight());
            }
        }
    };
    if (show) {
        updateDivider();
        mRecyclerView.setVisibility(VISIBLE);
        if (mRecyclerView.getTranslationY() == 0)
            mRecyclerView.setTranslationY(-mRecyclerView.getHeight());
    } else if (childCount > 0)
        translation = -mRecyclerView.getChildAt(childCount - 1).getBottom();
    else
        showDivider(false);
    ViewPropertyAnimatorCompat listAnim = ViewCompat.animate(mRecyclerView).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();
}
Also used : ViewPropertyAnimatorCompat(android.support.v4.view.ViewPropertyAnimatorCompat)

Aggregations

ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)46 View (android.view.View)40 RecyclerView (android.support.v7.widget.RecyclerView)33 ViewHolder (android.support.v7.widget.RecyclerView.ViewHolder)6 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)3 BezierDecelerateInterpolator (acr.browser.lightning.interpolator.BezierDecelerateInterpolator)2 ViewPropertyAnimatorListener (android.support.v4.view.ViewPropertyAnimatorListener)2 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)2 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 ViewPropertyAnimatorUpdateListener (android.support.v4.view.ViewPropertyAnimatorUpdateListener)1 AbsListView (android.widget.AbsListView)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 AnimatorViewHolder (im.actor.sdk.controllers.fragment.AnimatorViewHolder)1 AnimateViewHolder (jp.wasabeef.recyclerview.animators.holder.AnimateViewHolder)1