Example usage for android.animation ValueAnimator getValues

List of usage examples for android.animation ValueAnimator getValues

Introduction

In this page you can find the example usage for android.animation ValueAnimator getValues.

Prototype

public PropertyValuesHolder[] getValues() 

Source Link

Document

Returns the values that this ValueAnimator animates between.

Usage

From source file:com.taobao.weex.dom.transition.WXTransition.java

private void doLayoutPropertyValuesHolderAnimation(PropertyValuesHolder[] holders) {
    layoutValueAnimator = ValueAnimator.ofPropertyValuesHolder(holders);
    layoutValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override/*from ww  w.  j  ava  2s  .  co m*/
        public void onAnimationUpdate(ValueAnimator animation) {
            PropertyValuesHolder holders[] = animation.getValues();
            for (PropertyValuesHolder holder : holders) {
                String property = holder.getPropertyName();
                switch (property) {
                case Constants.Name.WIDTH: {
                    domObject.setStyleWidth((Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.HEIGHT: {
                    domObject.setStyleHeight((Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.MARGIN_TOP: {
                    domObject.setMargin(Spacing.TOP, (Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.MARGIN_LEFT: {
                    domObject.setMargin(Spacing.LEFT, (Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.MARGIN_RIGHT: {
                    domObject.setMargin(Spacing.RIGHT, (Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.MARGIN_BOTTOM: {
                    domObject.setMargin(Spacing.BOTTOM, (Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.LEFT: {
                    domObject.setPositionLeft((Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.RIGHT: {
                    domObject.setPositionRight((Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.BOTTOM: {
                    domObject.setPositionBottom((Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.TOP: {
                    domObject.setPositionTop((Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.PADDING_TOP: {
                    domObject.setPadding(Spacing.TOP, (Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.PADDING_BOTTOM: {
                    domObject.setPadding(Spacing.BOTTOM, (Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.PADDING_LEFT: {
                    domObject.setPadding(Spacing.LEFT, (Float) animation.getAnimatedValue(property));
                }
                    break;
                case Constants.Name.PADDING_RIGHT: {
                    domObject.setPadding(Spacing.RIGHT, (Float) animation.getAnimatedValue(property));
                }
                    break;
                default:
                    break;
                }
            }

            DOMActionContext domActionContext = WXSDKManager.getInstance().getWXDomManager()
                    .getDomContext(domObject.getDomContext().getInstanceId());
            if (domActionContext == null) {
                return;
            }
            domActionContext.markDirty();
            WXSDKManager.getInstance().getWXDomManager()
                    .sendEmptyMessageDelayed(WXDomHandler.MsgType.WX_DOM_TRANSITION_BATCH, 0);
            if (WXEnvironment.isApkDebugable()) {
                WXLogUtils.d("WXTransition send layout batch msg");
            }
        }
    });
    layoutValueAnimator.addListener(new AnimatorListenerAdapter() {

        boolean hasCancel = false;

        @Override
        public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            hasCancel = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (hasCancel) {
                return;
            }
            super.onAnimationEnd(animation);
            if (WXEnvironment.isApkDebugable()) {
                WXLogUtils.d("WXTransition layout onTransitionAnimationEnd " + domObject.getRef());
            }
            WXTransition.this.onTransitionAnimationEnd();
        }
    });
    if (interpolator != null) {
        layoutValueAnimator.setInterpolator(interpolator);
    }
    layoutValueAnimator.setStartDelay((long) (delay));
    layoutValueAnimator.setDuration((long) (duration));
    layoutValueAnimator.start();
}