use of com.taobao.weex.WXSDKInstance in project weex-example by KalicyZhou.
the class WXBridgeManager method reportJSException.
/**
* Report JavaScript Exception
*/
public void reportJSException(String instanceId, String function, String exception) {
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.e("reportJSException >>>> instanceId:" + instanceId + ", exception function:" + function + ", exception:" + exception);
}
WXSDKInstance instance;
if (instanceId != null && (instance = WXSDKManager.getInstance().getSDKInstance(instanceId)) != null) {
instance.onJSException(WXErrorCode.WX_ERR_JS_EXECUTE.getErrorCode(), function, exception);
String err = "function:" + function + "#exception:" + exception;
commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_JS_EXECUTE, err);
IWXJSExceptionAdapter adapter = WXSDKManager.getInstance().getIWXJSExceptionAdapter();
if (adapter != null) {
WXJSExceptionInfo jsException = new WXJSExceptionInfo(instanceId, instance.getBundleUrl(), WXErrorCode.WX_ERR_JS_EXECUTE.getErrorCode(), function, exception, null);
adapter.onJSException(jsException);
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d(jsException.toString());
}
}
}
}
use of com.taobao.weex.WXSDKInstance 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.WXSDKInstance in project weex-example by KalicyZhou.
the class WXEmbed method createInstance.
private WXSDKInstance createInstance() {
WXSDKInstance sdkInstance = getInstance().createNestedInstance(this);
getInstance().addOnInstanceVisibleListener(this);
sdkInstance.registerRenderListener(mListener);
String url = src;
if (mListener != null && mListener.mEventListener != null) {
url = mListener.mEventListener.transformUrl(src);
if (!mListener.mEventListener.onPreCreate(this, src)) {
//cancel render
return null;
}
}
if (TextUtils.isEmpty(url)) {
mListener.mEventListener.onException(this, WXRenderErrorCode.WX_USER_INTERCEPT_ERROR, "degradeToH5");
return sdkInstance;
}
ViewGroup.LayoutParams layoutParams = getHostView().getLayoutParams();
sdkInstance.renderByUrl(WXPerformance.DEFAULT, url, null, null, layoutParams.width, layoutParams.height, WXRenderStrategy.APPEND_ASYNC);
return sdkInstance;
}
use of com.taobao.weex.WXSDKInstance in project weex-example by KalicyZhou.
the class WXVideo method setSrc.
@WXComponentProp(name = Constants.Name.SRC)
public void setSrc(String src) {
if (TextUtils.isEmpty(src) || getHostView() == null) {
return;
}
if (!TextUtils.isEmpty(src)) {
WXSDKInstance instance = getInstance();
mWrapper.setVideoURI(instance.rewriteUri(Uri.parse(src), URIAdapter.VIDEO));
mWrapper.getProgressBar().setVisibility(View.VISIBLE);
}
}
use of com.taobao.weex.WXSDKInstance in project weex-example by KalicyZhou.
the class WXImage method setSrc.
@WXComponentProp(name = Constants.Name.SRC)
public void setSrc(String src) {
if (src == null) {
return;
}
WXSDKInstance instance = getInstance();
Uri rewrited = instance.rewriteUri(Uri.parse(src), URIAdapter.IMAGE);
if (Constants.Scheme.LOCAL.equals(rewrited.getScheme())) {
setLocalSrc(rewrited);
} else {
setRemoteSrc(rewrited);
}
}
Aggregations