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

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

Introduction

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

Prototype

public ViewPropertyAnimatorCompat alpha(float f) 

Source Link

Usage

From source file:jp.wasabeef.recyclerview.animators.AnimateChange.java

public void animateChange(final RecyclerView.ViewHolder oldHolder, final RecyclerView.ViewHolder newHolder,
        int fromX, int fromY, int toX, int toY) {
    final View view = oldHolder.itemView;
    final View newView = newHolder.itemView;
    long oldAnimDuration = (long) (0.5f * mDispatcher.getChangeDuration());
    long newAnimDuration = mDispatcher.getChangeDuration();

    if (view != null) {
        final ViewPropertyAnimatorCompat oldViewAnim = ViewCompat.animate(view);
        oldViewAnim.translationX(toX - fromX);
        oldViewAnim.translationY(toY - fromY);

        oldViewAnim.setDuration(oldAnimDuration);
        oldViewAnim.alpha(0).setListener(new ViewPropertyAnimatorListener() {
            @Override//from  w ww  .  j  a  va2s  .  com
            public void onAnimationStart(View view) {
                mDispatcher.dispatchChangeStarting(oldHolder, true);
            }

            @Override
            public void onAnimationEnd(View view) {
                oldViewAnim.setListener(null);
                ViewCompat.setAlpha(view, 1);
                ViewCompat.setTranslationX(view, 0);
                ViewCompat.setTranslationY(view, 0);
                mDispatcher.dispatchChangeFinished(oldHolder, true);
            }

            @Override
            public void onAnimationCancel(View view) {
                ViewHelper.clear(view);
            }
        }).start();
    }

    if (newView != null) {
        final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newView);
        newViewAnimation.translationX(0).translationY(0);

        newViewAnimation.setDuration(newAnimDuration);
        newViewAnimation.alpha(1).setListener(new ViewPropertyAnimatorListener() {
            @Override
            public void onAnimationStart(View view) {
                mDispatcher.dispatchChangeStarting(newHolder, false);
            }

            @Override
            public void onAnimationEnd(View view) {
                newViewAnimation.setListener(null);
                ViewCompat.setAlpha(newView, 1);
                ViewCompat.setTranslationX(newView, 0);
                ViewCompat.setTranslationY(newView, 0);
                mDispatcher.dispatchChangeFinished(newHolder, false);
            }

            @Override
            public void onAnimationCancel(View view) {
                ViewHelper.clear(view);
            }
        }).start();
    }
}

From source file:com.vicmns.demoinboxlikefab.SlideInOutLeftItemAnimator.java

@Override
protected void animateChangeImpl(final BaseItemAnimator.ChangeInfo changeInfo) {
    final RecyclerView.ViewHolder holder = changeInfo.oldHolder;
    final View view = holder.itemView;
    final RecyclerView.ViewHolder newHolder = changeInfo.newHolder;
    final View newView = newHolder != null ? newHolder.itemView : null;
    mChangeAnimations.add(changeInfo.oldHolder);

    final ViewPropertyAnimatorCompat oldViewAnim = ViewCompat.animate(view).setDuration(getChangeDuration());
    oldViewAnim.translationX(changeInfo.toX - changeInfo.fromX);
    oldViewAnim.translationY(changeInfo.toY - changeInfo.fromY);
    oldViewAnim.alpha(0).setListener(new VpaListenerAdapter() {
        @Override//  ww  w  .  ja  v a 2 s . c  om
        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) {
        mChangeAnimations.add(changeInfo.newHolder);
        final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newView);
        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();
    }
}

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

private void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    mAddAnimations.add(holder);// w  w w. ja v  a  2s  .c  o m
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    animation.alpha(1).setDuration(getAddDuration()).setListener(new VpaListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchAddStarting(holder);
        }

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

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            dispatchAddFinished(holder);
            mAddAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}

From source file:net.simonvt.cathode.widget.ScalingItemAnimator.java

private void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    addAnimations.add(holder);//from   ww w .j a va2s.  co m
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    animation.alpha(1).scaleY(1).setDuration(getAddDuration()).setListener(new VpaListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchAddStarting(holder);
        }

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

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            dispatchAddFinished(holder);
            addAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}

From source file:com.brioal.libmanager.itemanimator.BaseItemAnimator.java

private void animateAddImpl(final ViewHolder holder) {
    final ViewPropertyAnimatorCompat animation = onAnimatedAdd(holder);
    mAddAnimations.add(holder);//w w  w . jav a2 s . c  o  m
    animation.alpha(1).setDuration(getAddDuration()).setListener(new VpaListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchAddStarting(holder);
        }

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

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            dispatchAddFinished(holder);
            mAddAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}

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

private void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);/* w  w w. j  a  v a2s. c  o m*/
    animation.alpha(1).setDuration(getAddDuration()).setListener(new VpaListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchAddStarting(holder);
        }

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

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            dispatchAddFinished(holder);
            mAddAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}

From source file:com.bwie.myrecyclerviewdemo1.MyitemAnimator.java

void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);//from w  ww  .ja va 2s .c  o m
    animation.alpha(1).setDuration(getAddDuration()).setListener(new VpaListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchAddStarting(holder);
        }

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

        @Override
        public void onAnimationEnd(View view) {
            animation.setListener(null);
            dispatchAddFinished(holder);
            mAddAnimations.remove(holder);
            dispatchFinishedWhenDone();
        }
    }).start();
}

From source file:acr.browser.lightning.browser.fragment.anim.HorizontalItemAnimator.java

private void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);/*from w w w . j a va  2 s.co  m*/
    animation.alpha(1).translationY(0).setInterpolator(new BezierDecelerateInterpolator())
            .setDuration(getAddDuration()).setListener(new VpaListenerAdapter() {
                @Override
                public void onAnimationStart(View view) {
                    dispatchAddStarting(holder);
                }

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

                @Override
                public void onAnimationEnd(View view) {
                    animation.setListener(null);
                    dispatchAddFinished(holder);
                    mAddAnimations.remove(holder);
                    dispatchFinishedWhenDone();
                }
            }).start();
}

From source file:acr.browser.lightning.browser.fragment.anim.VerticalItemAnimator.java

private void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mAddAnimations.add(holder);//  ww  w  .  j  a v a2 s  .  c o m
    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();
}

From source file:bottombar.BottomBarTab.java

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

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