use of com.taobao.weex.bridge.JSCallback in project incubator-weex by apache.
the class WXModalUIModuleTest method testAlert.
@Test
public void testAlert() throws Exception {
JSCallback callback = Mockito.mock(JSCallback.class);
module.alert(JSON.parseObject("{}"), callback);
}
use of com.taobao.weex.bridge.JSCallback in project incubator-weex by apache.
the class WXNavigatorModule method close.
@JSMethod(uiThread = true)
public void close(JSONObject options, JSCallback success, JSCallback failure) {
JSONObject result = new JSONObject();
JSCallback callback = null;
if (mWXSDKInstance.getContext() instanceof Activity) {
callback = success;
((Activity) mWXSDKInstance.getContext()).finish();
} else {
result.put(CALLBACK_RESULT, MSG_FAILED);
result.put(CALLBACK_MESSAGE, "Close page failed.");
callback = failure;
}
if (callback != null) {
callback.invoke(result);
}
}
use of com.taobao.weex.bridge.JSCallback in project incubator-weex by apache.
the class WXNavigatorModule method open.
@JSMethod(uiThread = true)
public void open(JSONObject options, JSCallback success, JSCallback failure) {
if (options != null) {
String url = options.getString(Constants.Value.URL);
JSCallback callback = success;
JSONObject result = new JSONObject();
if (!TextUtils.isEmpty(url)) {
Uri rawUri = Uri.parse(url);
String scheme = rawUri.getScheme();
if (TextUtils.isEmpty(scheme) || Constants.Scheme.HTTP.equalsIgnoreCase(scheme) || Constants.Scheme.HTTPS.equalsIgnoreCase(scheme)) {
this.push(options.toJSONString(), success);
} else {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, rawUri);
mWXSDKInstance.getContext().startActivity(intent);
result.put(CALLBACK_RESULT, MSG_SUCCESS);
} catch (Throwable e) {
e.printStackTrace();
result.put(CALLBACK_RESULT, MSG_FAILED);
result.put(CALLBACK_MESSAGE, "Open page failed.");
callback = failure;
}
}
} else {
result.put(CALLBACK_RESULT, MSG_PARAM_ERR);
result.put(CALLBACK_MESSAGE, "The URL parameter is empty.");
callback = failure;
}
if (callback != null) {
callback.invoke(result);
}
}
}
Aggregations