Search in sources :

Example 26 with WXSDKInstance

use of com.taobao.weex.WXSDKInstance in project weex-example by KalicyZhou.

the class WXDomStatement method layout.

void layout(WXDomObject rootDom) {
    if (rootDom == null) {
        return;
    }
    long start0 = System.currentTimeMillis();
    rebuildingFixedDomTree(rootDom);
    rootDom.traverseTree(new WXDomObject.Consumer() {

        @Override
        public void accept(WXDomObject dom) {
            if (!dom.hasUpdate() || mDestroy) {
                return;
            }
            dom.layoutBefore();
        }
    });
    long start = System.currentTimeMillis();
    rootDom.calculateLayout(mLayoutContext);
    WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
    if (instance != null) {
        instance.cssLayoutTime(System.currentTimeMillis() - start);
    }
    rootDom.traverseTree(new WXDomObject.Consumer() {

        @Override
        public void accept(WXDomObject dom) {
            if (!dom.hasUpdate() || mDestroy) {
                return;
            }
            dom.layoutAfter();
        }
    });
    start = System.currentTimeMillis();
    rootDom.traverseTree(new ApplyUpdateConsumer());
    if (instance != null) {
        instance.applyUpdateTime(System.currentTimeMillis() - start);
    }
    start = System.currentTimeMillis();
    updateDomObj();
    if (instance != null) {
        instance.updateDomObjTime(System.currentTimeMillis() - start);
    }
    parseAnimation();
    int count = mNormalTasks.size();
    for (int i = 0; i < count && !mDestroy; ++i) {
        mWXRenderManager.runOnThread(mInstanceId, mNormalTasks.get(i));
    }
    mNormalTasks.clear();
    mAddDom.clear();
    animations.clear();
    mDirty = false;
    if (instance != null) {
        instance.batchTime(System.currentTimeMillis() - start0);
    }
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance)

Example 27 with WXSDKInstance

use of com.taobao.weex.WXSDKInstance in project weex-example by KalicyZhou.

the class WXDomStatement method createFinish.

/**
   * Create a command object for notifying {@link WXRenderManager} that the process of creating
   * given view is finished, and put the command object in the queue.
   */
void createFinish() {
    if (mDestroy) {
        return;
    }
    final WXDomObject root = mRegistry.get(WXDomObject.ROOT);
    mNormalTasks.add(new IWXRenderTask() {

        @Override
        public void execute() {
            mWXRenderManager.createFinish(mInstanceId, (int) root.getLayoutWidth(), (int) root.getLayoutHeight());
        }

        @Override
        public String toString() {
            return "createFinish";
        }
    });
    mDirty = true;
    WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
    if (instance != null) {
        instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
    }
}
Also used : IWXRenderTask(com.taobao.weex.ui.IWXRenderTask) WXSDKInstance(com.taobao.weex.WXSDKInstance)

Example 28 with WXSDKInstance

use of com.taobao.weex.WXSDKInstance in project weex-example by KalicyZhou.

the class AbstractWeexActivity method createWeexInstance.

protected void createWeexInstance() {
    destoryWeexInstance();
    Rect outRect = new Rect();
    getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
    mInstance = new WXSDKInstance(this);
    mInstance.registerRenderListener(this);
}
Also used : Rect(android.graphics.Rect) WXSDKInstance(com.taobao.weex.WXSDKInstance)

Example 29 with WXSDKInstance

use of com.taobao.weex.WXSDKInstance in project weex-example by KalicyZhou.

the class AbsWeexActivity method createWeexInstance.

protected void createWeexInstance() {
    destoryWeexInstance();
    mInstance = new WXSDKInstance(this);
    mInstance.registerRenderListener(this);
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance)

Example 30 with WXSDKInstance

use of com.taobao.weex.WXSDKInstance in project weex-example by KalicyZhou.

the class WXPageActivity method loadWXfromService.

private void loadWXfromService(final String url) {
    mProgressBar.setVisibility(View.VISIBLE);
    if (mInstance != null) {
        mInstance.destroy();
    }
    RenderContainer renderContainer = new RenderContainer(this);
    mContainer.addView(renderContainer);
    mInstance = new WXSDKInstance(this);
    mInstance.setRenderContainer(renderContainer);
    mInstance.registerRenderListener(this);
    mInstance.setNestedInstanceInterceptor(this);
    mInstance.setBundleUrl(url);
    mInstance.setTrackComponent(true);
    WXHttpTask httpTask = new WXHttpTask();
    httpTask.url = url;
    httpTask.requestListener = new WXRequestListener() {

        @Override
        public void onSuccess(WXHttpTask task) {
            Log.i(TAG, "into--[http:onSuccess] url:" + url);
            try {
                mConfigMap.put("bundleUrl", url);
                mInstance.render(TAG, new String(task.response.data, "utf-8"), mConfigMap, null, ScreenUtil.getDisplayWidth(WXPageActivity.this), ScreenUtil.getDisplayHeight(WXPageActivity.this), WXRenderStrategy.APPEND_ASYNC);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onError(WXHttpTask task) {
            Log.i(TAG, "into--[http:onError]");
            mProgressBar.setVisibility(View.GONE);
            Toast.makeText(getApplicationContext(), "network error!", Toast.LENGTH_SHORT).show();
        }
    };
    WXHttpManager.getInstance().sendRequest(httpTask);
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) RenderContainer(com.taobao.weex.RenderContainer) WXHttpTask(com.alibaba.weex.https.WXHttpTask) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WXRequestListener(com.alibaba.weex.https.WXRequestListener)

Aggregations

WXSDKInstance (com.taobao.weex.WXSDKInstance)30 IWXRenderTask (com.taobao.weex.ui.IWXRenderTask)10 WXDomObject (com.taobao.weex.dom.WXDomObject)3 Spacing (com.taobao.weex.dom.flex.Spacing)3 WXComponent (com.taobao.weex.ui.component.WXComponent)3 Before (org.junit.Before)3 Rect (android.graphics.Rect)2 RenderContainer (com.taobao.weex.RenderContainer)2 Activity (android.app.Activity)1 Uri (android.net.Uri)1 ArrayMap (android.support.v4.util.ArrayMap)1 ViewGroup (android.view.ViewGroup)1 JSONObject (com.alibaba.fastjson.JSONObject)1 WXHttpTask (com.alibaba.weex.https.WXHttpTask)1 WXRequestListener (com.alibaba.weex.https.WXRequestListener)1 WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)1 IWXJSExceptionAdapter (com.taobao.weex.adapter.IWXJSExceptionAdapter)1 IWXUserTrackAdapter (com.taobao.weex.adapter.IWXUserTrackAdapter)1 WXErrorCode (com.taobao.weex.common.WXErrorCode)1 WXException (com.taobao.weex.common.WXException)1