Search in sources :

Example 1 with WXAnimationBean

use of com.taobao.weex.ui.animation.WXAnimationBean in project weex-example by KalicyZhou.

the class WXDomStatement method startAnimation.

void startAnimation(@NonNull final String ref, @NonNull String animation, @Nullable final String callBack) {
    if (mDestroy) {
        return;
    }
    WXDomObject domObject = mRegistry.get(ref);
    if (domObject == null) {
        return;
    }
    final WXAnimationBean animationBean = createAnimationBean(ref, animation);
    if (animationBean != null) {
        mNormalTasks.add(new IWXRenderTask() {

            @Override
            public void execute() {
                mWXRenderManager.startAnimation(mInstanceId, ref, animationBean, callBack);
            }

            @Override
            public String toString() {
                return "startAnimationByCall";
            }
        });
        mDirty = true;
    }
}
Also used : IWXRenderTask(com.taobao.weex.ui.IWXRenderTask) WXAnimationBean(com.taobao.weex.ui.animation.WXAnimationBean)

Example 2 with WXAnimationBean

use of com.taobao.weex.ui.animation.WXAnimationBean in project weex-example by KalicyZhou.

the class WXDomStatement method createAnimationBean.

private WXAnimationBean createAnimationBean(String ref, String animation) {
    try {
        WXAnimationBean animationBean = JSONObject.parseObject(animation, WXAnimationBean.class);
        if (animationBean != null && animationBean.styles != null) {
            WXDomObject domObject = mRegistry.get(ref);
            int width = (int) domObject.getLayoutWidth();
            int height = (int) domObject.getLayoutHeight();
            animationBean.styles.init(animationBean.styles.transformOrigin, animationBean.styles.transform, width, height, WXSDKManager.getInstance().getSDKInstance(mInstanceId).getViewPortWidth());
        }
        return animationBean;
    } catch (RuntimeException e) {
        WXLogUtils.e("", e);
        return null;
    }
}
Also used : WXAnimationBean(com.taobao.weex.ui.animation.WXAnimationBean)

Example 3 with WXAnimationBean

use of com.taobao.weex.ui.animation.WXAnimationBean in project weex-example by KalicyZhou.

the class WXDomStatement method createAnimationBean.

private WXAnimationBean createAnimationBean(String ref, Map<String, Object> style) {
    if (style != null) {
        try {
            Object transform = style.get(WXDomObject.TRANSFORM);
            if (transform instanceof String && !TextUtils.isEmpty((String) transform)) {
                String transformOrigin = (String) style.get(WXDomObject.TRANSFORM_ORIGIN);
                WXAnimationBean animationBean = new WXAnimationBean();
                WXDomObject domObject = mRegistry.get(ref);
                int width = (int) domObject.getLayoutWidth();
                int height = (int) domObject.getLayoutHeight();
                animationBean.styles = new WXAnimationBean.Style();
                animationBean.styles.init(transformOrigin, (String) transform, width, height, WXSDKManager.getInstance().getSDKInstance(mInstanceId).getViewPortWidth());
                return animationBean;
            }
        } catch (RuntimeException e) {
            WXLogUtils.e("", e);
            return null;
        }
    }
    return null;
}
Also used : WXAnimationBean(com.taobao.weex.ui.animation.WXAnimationBean) JSONObject(com.alibaba.fastjson.JSONObject)

Aggregations

WXAnimationBean (com.taobao.weex.ui.animation.WXAnimationBean)3 JSONObject (com.alibaba.fastjson.JSONObject)1 IWXRenderTask (com.taobao.weex.ui.IWXRenderTask)1