use of com.taobao.weex.ui.animation.WidthProperty 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;
}
}
Aggregations