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

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

Introduction

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

Prototype

public ViewPropertyAnimatorCompat scaleY(float f) 

Source Link

Usage

From source file:com.example.administrator.demorecyler.MyItemAnimator.java

/**
 * //from w ww  .  j a v a  2s  .  com
 * @param holder
 */
private void animateAddImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    mAddAnimations.add(holder);
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    animation.scaleY(1).rotationBy(360).setDuration(getAddDuration()).setListener(new VpaListenerAdapter() {
        @Override
        public void onAnimationStart(View view) {
            dispatchAddStarting(holder);
        }

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

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

From source file:com.mwang.irregulargridview.DynamicItemAnimator.java

private void animateChangeImpl(final ChangeInfo changeInfo) {
    final RecyclerView.ViewHolder holder = changeInfo.oldHolder;
    final View view = holder == null ? null : holder.itemView;
    final RecyclerView.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);
        float scaleX = (float) changeInfo.toWidth / changeInfo.fromWidth;
        float scaleY = (float) changeInfo.toHeight / changeInfo.fromHeight;
        if (scaleX == 0)
            scaleX = 1;/*from  www  .j av  a2s  .c om*/
        if (scaleY == 0)
            scaleY = 1;

        oldViewAnim.scaleX(scaleX);
        oldViewAnim.scaleY(scaleY);
        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);
                ViewCompat.setScaleX(view, 1);
                ViewCompat.setScaleY(view, 1);
                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).scaleX(1).scaleY(1).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);
                        ViewCompat.setScaleX(view, 1);
                        ViewCompat.setScaleY(view, 1);
                        dispatchChangeFinished(changeInfo.newHolder, false);
                        mChangeAnimations.remove(changeInfo.newHolder);
                        dispatchFinishedWhenDone();
                    }
                }).start();
    }
}