Search in sources :

Example 11 with JSCallback

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);
}
Also used : JSCallback(com.taobao.weex.bridge.JSCallback) Test(org.junit.Test) WXSDKInstanceTest(com.taobao.weex.WXSDKInstanceTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with JSCallback

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);
}
Also used : JSCallback(com.taobao.weex.bridge.JSCallback) Test(org.junit.Test) WXSDKInstanceTest(com.taobao.weex.WXSDKInstanceTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with JSCallback

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;
    }
}
Also used : EventRightItem(com.benmu.framework.event.nav.EventRightItem) EventNavigationInfo(com.benmu.framework.event.nav.EventNavigationInfo) EventImage(com.benmu.framework.event.camera.EventImage) EventDismissLoading(com.benmu.framework.event.modal.EventDismissLoading) EventBack(com.benmu.framework.event.router.EventBack) EventBrowse(com.benmu.framework.event.browse.EventBrowse) EventOpenBrowser(com.benmu.framework.event.router.EventOpenBrowser) EventSetHomePage(com.benmu.framework.event.router.EventSetHomePage) EventShare(com.benmu.framework.event.share.EventShare) EventAuth(com.benmu.framework.event.auth.EventAuth) EventCamera(com.benmu.framework.event.camera.EventCamera) EventAlert(com.benmu.framework.event.modal.EventAlert) EventGetBackParams(com.benmu.framework.event.router.EventGetBackParams) EventLeftItem(com.benmu.framework.event.nav.EventLeftItem) Context(android.content.Context) EventGetParams(com.benmu.framework.event.router.EventGetParams) EventRefresh(com.benmu.framework.event.router.EventRefresh) EventPay(com.benmu.framework.event.pay.EventPay) EventRemoveData(com.benmu.framework.event.shorage.EventRemoveData) EventTool(com.benmu.framework.event.tool.EventTool) EventNav(com.benmu.framework.event.router.EventNav) EventWebView(com.benmu.framework.event.router.EventWebView) EventSetData(com.benmu.framework.event.shorage.EventSetData) EventToMap(com.benmu.framework.event.router.EventToMap) EventGetData(com.benmu.framework.event.shorage.EventGetData) EventOpen(com.benmu.framework.event.router.EventOpen) EventFinish(com.benmu.framework.event.router.EventFinish) EventToast(com.benmu.framework.event.modal.EventToast) JSCallback(com.taobao.weex.bridge.JSCallback) EventCall(com.benmu.framework.event.router.EventCall) EventDeleteData(com.benmu.framework.event.shorage.EventDeleteData) EventFetch(com.benmu.framework.event.http.EventFetch) EventCenterItem(com.benmu.framework.event.nav.EventCenterItem) EventShowLoading(com.benmu.framework.event.modal.EventShowLoading) EventConfirm(com.benmu.framework.event.modal.EventConfirm) Subscribe(com.squareup.otto.Subscribe)

Example 14 with JSCallback

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);
}
Also used : WeexEventBean(com.benmu.framework.model.WeexEventBean) ArrayList(java.util.ArrayList) JSCallback(com.taobao.weex.bridge.JSCallback) JSMethod(com.taobao.weex.annotation.JSMethod)

Aggregations

JSCallback (com.taobao.weex.bridge.JSCallback)14 JSMethod (com.taobao.weex.annotation.JSMethod)7 WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)5 Test (org.junit.Test)5 WeexEventBean (com.benmu.framework.model.WeexEventBean)4 ArrayList (java.util.ArrayList)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 JSONObject (com.alibaba.fastjson.JSONObject)2 Activity (android.app.Activity)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 EventAuth (com.benmu.framework.event.auth.EventAuth)1 EventBrowse (com.benmu.framework.event.browse.EventBrowse)1 EventCamera (com.benmu.framework.event.camera.EventCamera)1 EventImage (com.benmu.framework.event.camera.EventImage)1 EventFetch (com.benmu.framework.event.http.EventFetch)1 EventAlert (com.benmu.framework.event.modal.EventAlert)1 EventConfirm (com.benmu.framework.event.modal.EventConfirm)1