Search in sources :

Example 1 with HeightProperty

use of com.taobao.weex.ui.animation.HeightProperty in project incubator-weex by apache.

the class AnimationAction method createAnimator.

@Nullable
private ObjectAnimator createAnimator(final View target, final int viewPortWidth) {
    if (target == null) {
        return null;
    }
    WXAnimationBean.Style style = mAnimationBean.styles;
    if (style != null) {
        ObjectAnimator animator;
        List<PropertyValuesHolder> holders = style.getHolders();
        if (!TextUtils.isEmpty(style.backgroundColor)) {
            BorderDrawable borderDrawable;
            if ((borderDrawable = WXViewUtils.getBorderDrawable(target)) != null) {
                holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(), borderDrawable.getColor(), WXResourceUtils.getColor(style.backgroundColor)));
            } else if (target.getBackground() instanceof ColorDrawable) {
                holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(), ((ColorDrawable) target.getBackground()).getColor(), WXResourceUtils.getColor(style.backgroundColor)));
            }
        }
        if (target.getLayoutParams() != null && (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
            ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
            if (!TextUtils.isEmpty(style.width)) {
                holders.add(PropertyValuesHolder.ofInt(new WidthProperty(), layoutParams.width, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width), viewPortWidth)));
            }
            if (!TextUtils.isEmpty(style.height)) {
                holders.add(PropertyValuesHolder.ofInt(new HeightProperty(), layoutParams.height, (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height), viewPortWidth)));
            }
        }
        if (style.getPivot() != null) {
            Pair<Float, Float> pair = style.getPivot();
            target.setPivotX(pair.first);
            target.setPivotY(pair.second);
        }
        animator = ObjectAnimator.ofPropertyValuesHolder(target, holders.toArray(new PropertyValuesHolder[holders.size()]));
        animator.setStartDelay(mAnimationBean.delay);
        return animator;
    } else {
        return null;
    }
}
Also used : WXAnimationBean(com.taobao.weex.ui.animation.WXAnimationBean) ObjectAnimator(android.animation.ObjectAnimator) ViewGroup(android.view.ViewGroup) ArgbEvaluator(android.animation.ArgbEvaluator) BackgroundColorProperty(com.taobao.weex.ui.animation.BackgroundColorProperty) WidthProperty(com.taobao.weex.ui.animation.WidthProperty) HeightProperty(com.taobao.weex.ui.animation.HeightProperty) BorderDrawable(com.taobao.weex.ui.view.border.BorderDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) PropertyValuesHolder(android.animation.PropertyValuesHolder) Nullable(android.support.annotation.Nullable)

Aggregations

ArgbEvaluator (android.animation.ArgbEvaluator)1 ObjectAnimator (android.animation.ObjectAnimator)1 PropertyValuesHolder (android.animation.PropertyValuesHolder)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Nullable (android.support.annotation.Nullable)1 ViewGroup (android.view.ViewGroup)1 BackgroundColorProperty (com.taobao.weex.ui.animation.BackgroundColorProperty)1 HeightProperty (com.taobao.weex.ui.animation.HeightProperty)1 WXAnimationBean (com.taobao.weex.ui.animation.WXAnimationBean)1 WidthProperty (com.taobao.weex.ui.animation.WidthProperty)1 BorderDrawable (com.taobao.weex.ui.view.border.BorderDrawable)1