use of com.taobao.weex.bridge.JSCallback in project weex-example by KalicyZhou.
the class WXModalUIModuleTest method testConfirm.
@Test
public void testConfirm() throws Exception {
JSCallback callback = Mockito.mock(JSCallback.class);
module.confirm("{}", callback);
}
use of com.taobao.weex.bridge.JSCallback in project weex-example by KalicyZhou.
the class WXModalUIModuleTest method testAlert.
@Test
public void testAlert() throws Exception {
JSCallback callback = Mockito.mock(JSCallback.class);
module.alert("{}", callback);
}
use of com.taobao.weex.bridge.JSCallback in project WeexErosFramework by bmfe.
the class DispatchEventCenter method onWeexEvent.
@Subscribe
public void onWeexEvent(WeexEventBean weexEventBean) {
if (weexEventBean == null)
return;
Context context = safeContext(weexEventBean.getContext());
if (context == null)
return;
String params = weexEventBean.getJsParams();
switch(weexEventBean.getKey()) {
case WXConstant.WXEventCenter.EVENT_PAYBYWECHAT:
if (TextUtils.isEmpty(params))
return;
new EventPay().pay(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_OPEN:
if (TextUtils.isEmpty(params))
return;
if (weexEventBean.getCallbacks() != null) {
new EventOpen().open(params, context, weexEventBean.getCallbacks());
} else if (weexEventBean.getJscallback() != null) {
new EventOpen().open(params, context, weexEventBean.getJscallback());
} else {
new EventOpen().open(params, context);
}
break;
case WXConstant.WXEventCenter.EVENT_GETPARAMS:
new EventGetParams().getParams(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_BACK:
new EventBack().back(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_GETBACKPARAMS:
new EventGetBackParams().getBackParams(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_REFRESH:
new EventRefresh().refresh(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_FINISH:
new EventFinish().finish(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_TOMAP:
new EventToMap().toMap(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_TOWEBVIEW:
new EventWebView().toWebView(params, context);
break;
case WXConstant.WXEventCenter.EVENT_CALL:
new EventCall().call(params, context);
break;
case WXConstant.WXEventCenter.EVENT_SETDATA:
new EventSetData().setData(context, weexEventBean.getParamsList(), weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_GETDATA:
new EventGetData().getData(context, weexEventBean.getParamsList(), weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_DELETEDATA:
new EventDeleteData().deleteData(context, weexEventBean.getParamsList(), weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_REMOVEDATA:
new EventRemoveData().removeData(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_BROWSERIMG:
if (TextUtils.isEmpty(params))
return;
new EventBrowse().open(params, context);
break;
case WXConstant.WXEventCenter.EVENT_MODAL_ALERT:
if (TextUtils.isEmpty(params))
return;
JSCallback modal_alert_callback = weexEventBean.getJscallback();
new EventAlert().alert(params, modal_alert_callback, context);
break;
case WXConstant.WXEventCenter.EVENT_MODAL_CONFIRM:
if (TextUtils.isEmpty(params))
return;
ArrayList<JSCallback> callbacks = weexEventBean.getCallbacks();
if (callbacks == null && callbacks.size() < 2)
return;
new EventConfirm().confirm(params, callbacks.get(0), callbacks.get(1), context);
break;
case WXConstant.WXEventCenter.EVENT_MODAL_SHOWLOADING:
if (TextUtils.isEmpty(params))
return;
JSCallback modal_showloading_callback = weexEventBean.getJscallback();
new EventShowLoading().showLoading(params, modal_showloading_callback, context);
break;
case WXConstant.WXEventCenter.EVENT_MODAL_TOAST:
if (TextUtils.isEmpty(params))
return;
new EventToast().toast(params, context);
break;
case WXConstant.WXEventCenter.EVENT_FETCH:
new EventFetch().fetch(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_CAMERA_UPLOADIMAGE:
new EventCamera().uploadImage(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_CAMERA_PATH:
new EventCamera().openCamera(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_CAMERA:
JSCallback jscallback = weexEventBean.getJscallback();
new EventCamera().scan(jscallback, context);
break;
case WXConstant.WXEventCenter.EVENT_RIGHTITEM:
new EventRightItem().setRightItem(params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_LEFTITEM:
new EventLeftItem().setLeftItem(params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_CENTERITEM:
new EventCenterItem().setCenterItem(params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_NAVIGATIONINFO:
new EventNavigationInfo().setNavigationInfo(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_RESIGNKEYBOARD:
new EventTool().resignKeyboard(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_ISINSTALLWXAPP:
new EventTool().isWXInstall(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_GETCID:
new EventTool().getCid(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_COPYSTRING:
new EventTool().copyString(context, params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_MODAL_DISMISSLOADING:
new EventDismissLoading().dismiss(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_SHARE:
new EventShare().share(context, params, weexEventBean.getCallbacks().get(0), weexEventBean.getCallbacks().get(1));
break;
case WXConstant.WXEventCenter.EVENT_RELAYTOFRIEND:
new EventShare().relayToFriend(context, params, weexEventBean.getCallbacks());
break;
case WXConstant.WXEventCenter.EVENT_RELAYTOCRICLE:
new EventShare().relayToCricle(context, params, weexEventBean.getCallbacks());
break;
case WXConstant.WXEventCenter.EVENT_WECHATLOGIN:
new EventAuth().wechat(context, params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_OPENBROWSER:
new EventOpenBrowser().openBrowser(context, params, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_COMMUNICATION_SMS:
new EventCommunication().sms(weexEventBean.getExpand().toString(), params, context);
break;
case WXConstant.WXEventCenter.EVENT_COMMUNICATION_CONTACTS:
new EventCommunication().contacts(context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_SET_HOMEPAGE:
new EventSetHomePage().setHomePage(context, params);
break;
case WXConstant.WXEventCenter.EVENT_IMAGE_PICK:
new EventImage().pick(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_IMAGE_UPLOAD:
new EventFetch().uploadImage(params, context, weexEventBean.getJscallback());
break;
case WXConstant.WXEventCenter.EVENT_NAV:
new EventNav().nav(params, context);
break;
case WXConstant.WXEventCenter.EVENT_GEOLOCATION_GET:
reflectionClazzPerform("com.plugamap.EventGeo", context, params, weexEventBean.getJscallback(), "");
break;
default:
break;
}
}
use of com.taobao.weex.bridge.JSCallback in project WeexErosFramework by bmfe.
the class ShareModule method relayToFriend.
@JSMethod
public void relayToFriend(String params, JSCallback successCallback, JSCallback failedCallback) {
WeexEventBean weexEventBean = new WeexEventBean();
weexEventBean.setKey(WXConstant.WXEventCenter.EVENT_RELAYTOFRIEND);
weexEventBean.setContext(mWXSDKInstance.getContext());
weexEventBean.setJsParams(params);
ArrayList<JSCallback> callbacks = new ArrayList<>();
callbacks.add(successCallback);
callbacks.add(failedCallback);
weexEventBean.setCallbacks(callbacks);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(weexEventBean);
}
use of com.taobao.weex.bridge.JSCallback in project weiui by kuaifan.
the class weiuiAlertDialog method alert.
public static void alert(Context context, Object object, JSCallback callback) {
JSONObject json = weiuiJson.parseObject(object);
if (json.size() == 0) {
json.put("message", object);
}
//
JSONObject newJson = new JSONObject();
newJson.put("title", json.get("title"));
newJson.put("message", json.get("message"));
newJson.put("buttons", "[{title:'" + weiuiJson.getString(json, "button", "确定") + "'}]");
newJson.put("cancelable", json.get("cancelable"));
Builder(context, newJson, new JSCallback() {
@Override
public void invoke(Object data) {
Map<String, Object> res = weiuiMap.objectToMap(data);
if (weiuiParse.parseStr(res.get("status")).equals("click")) {
if (callback != null) {
callback.invoke(null);
}
}
}
@Override
public void invokeAndKeepAlive(Object data) {
}
});
}
Aggregations