use of com.taobao.weex.RenderContainer in project weex-example by KalicyZhou.
the class WXPageActivity method loadWXfromLocal.
private void loadWXfromLocal(boolean reload) {
if (reload && mInstance != null) {
mInstance.destroy();
mInstance = null;
}
if (mInstance == null) {
RenderContainer renderContainer = new RenderContainer(this);
mInstance = new WXSDKInstance(this);
mInstance.setRenderContainer(renderContainer);
mInstance.registerRenderListener(this);
mInstance.setNestedInstanceInterceptor(this);
mInstance.setTrackComponent(true);
}
mContainer.post(new Runnable() {
@Override
public void run() {
Activity ctx = WXPageActivity.this;
Rect outRect = new Rect();
ctx.getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
mConfigMap.put("bundleUrl", mUri.toString());
String path = mUri.getScheme().equals("file") ? assembleFilePath(mUri) : mUri.toString();
mInstance.render(TAG, WXFileUtils.loadAsset(path, WXPageActivity.this), mConfigMap, null, WXRenderStrategy.APPEND_ASYNC);
}
});
}
use of com.taobao.weex.RenderContainer 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);
}
Aggregations