use of com.taobao.weex.bridge.JSCallback in project weex-example by KalicyZhou.
the class WXStreamModuleTest method testFetchRequestHttpbinCallback.
@Test
public void testFetchRequestHttpbinCallback() throws Exception {
WXStreamModule streamModule = createModule(new DefaultWXHttpAdapter());
JSCallback progress = mock(JSCallback.class);
JSCallback finish = mock(JSCallback.class);
System.out.print("request start " + System.currentTimeMillis());
streamModule.fetch("{method: 'POST',url: 'http://httpbin.org/post',type:'json'}", finish, progress);
verify(progress, timeout(10 * 1000).atLeastOnce()).invokeAndKeepAlive(anyMapOf(String.class, Object.class));
verify(finish, timeout(10 * 1000).times(1)).invoke(anyMapOf(String.class, Object.class));
System.out.print("\nrequest finish" + System.currentTimeMillis());
}
use of com.taobao.weex.bridge.JSCallback in project weex-example by KalicyZhou.
the class WXModalUIModuleTest method testPrompt.
@Test
public void testPrompt() throws Exception {
JSCallback callback = Mockito.mock(JSCallback.class);
module.prompt("{}", callback);
}
use of com.taobao.weex.bridge.JSCallback in project WeexErosFramework by bmfe.
the class EventOpen method open.
public void open(String params, Context context, List<JSCallback> callbacks) {
JSCallback backCallback = null;
JSCallback resultCallback = null;
if (callbacks.size() > 1) {
backCallback = callbacks.get(0);
resultCallback = callbacks.get(1);
} else if (callbacks.size() > 0) {
backCallback = callbacks.get(0);
}
RouterManager routerManager = ManagerFactory.getManagerService(RouterManager.class);
boolean result = routerManager.open(context, params, backCallback);
if (resultCallback != null) {
resultCallback.invoke(result ? WXConstant.OPEN_PAGE_SUCCESS : WXConstant.OPNE_PAGE_FAILED);
}
}
use of com.taobao.weex.bridge.JSCallback in project WeexErosFramework by bmfe.
the class ModalModule method confirm.
@JSMethod(uiThread = true)
public void confirm(String options, final JSCallback cancel, final JSCallback ok) {
WeexEventBean eventBean = new WeexEventBean();
eventBean.setContext(mWXSDKInstance.getContext());
eventBean.setKey(WXConstant.WXEventCenter.EVENT_MODAL_CONFIRM);
eventBean.setJsParams(options);
ArrayList<JSCallback> jsCallbacks = new ArrayList<>();
jsCallbacks.add(cancel);
jsCallbacks.add(ok);
eventBean.setCallbacks(jsCallbacks);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(eventBean);
}
use of com.taobao.weex.bridge.JSCallback in project WeexErosFramework by bmfe.
the class RouterModule method open.
@JSMethod(uiThread = true)
public void open(String params, JSCallback backCallback, JSCallback resultCallback) {
WeexEventBean eventBean = new WeexEventBean();
eventBean.setKey(WXConstant.WXEventCenter.EVENT_OPEN);
eventBean.setJsParams(params);
ArrayList<JSCallback> callBacks = new ArrayList<>();
callBacks.add(backCallback);
callBacks.add(resultCallback);
eventBean.setCallbacks(callBacks);
eventBean.setContext(mWXSDKInstance.getContext());
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(eventBean);
}
Aggregations