Search in sources :

Example 6 with JSCallback

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

Example 7 with JSCallback

use of com.taobao.weex.bridge.JSCallback in project WeexErosFramework by bmfe.

the class ShareModule method share.

@JSMethod
public void share(String params, JSCallback success, JSCallback fail) {
    WeexEventBean weexEventBean = new WeexEventBean();
    weexEventBean.setKey(WXConstant.WXEventCenter.EVENT_SHARE);
    weexEventBean.setContext(mWXSDKInstance.getContext());
    weexEventBean.setJsParams(params);
    ArrayList<JSCallback> callbacks = new ArrayList<>();
    callbacks.add(success);
    callbacks.add(fail);
    weexEventBean.setCallbacks(callbacks);
    ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(weexEventBean);
// if (params == null) {
// return;
// }
// ShareBean shareBean = BMJsonParsManager.parseObject(params, ShareBean.class);
// BMShareManager.getInstance().share((Activity) mWXSDKInstance.getContext(), shareBean,
// mWXSDKInstance.getContainerView(), success, fail);
}
Also used : WeexEventBean(com.benmu.framework.model.WeexEventBean) ArrayList(java.util.ArrayList) JSCallback(com.taobao.weex.bridge.JSCallback) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 8 with JSCallback

use of com.taobao.weex.bridge.JSCallback in project WeexErosFramework by bmfe.

the class ShareModule method relayToCricle.

@JSMethod
public void relayToCricle(String params, JSCallback successCallback, JSCallback failedCallback) {
    WeexEventBean weexEventBean = new WeexEventBean();
    weexEventBean.setKey(WXConstant.WXEventCenter.EVENT_RELAYTOCRICLE);
    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)

Example 9 with JSCallback

use of com.taobao.weex.bridge.JSCallback in project weex-example by KalicyZhou.

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);
        }
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Intent(android.content.Intent) Uri(android.net.Uri) JSCallback(com.taobao.weex.bridge.JSCallback) JSMethod(com.taobao.weex.annotation.JSMethod)

Example 10 with JSCallback

use of com.taobao.weex.bridge.JSCallback in project weex-example by KalicyZhou.

the class WXClipboardModuleTest method testGetString.

@Test
public void testGetString() throws Exception {
    JSCallback mock = Mockito.mock(JSCallback.class);
    module.getString(mock);
    Mockito.verify(mock, Mockito.times(1)).invoke(Mockito.anyObject());
    testSetString();
    mock = Mockito.mock(JSCallback.class);
    module.getString(mock);
    Mockito.verify(mock, Mockito.times(1)).invoke(Mockito.anyObject());
}
Also used : JSCallback(com.taobao.weex.bridge.JSCallback) Test(org.junit.Test) WXSDKInstanceTest(com.taobao.weex.WXSDKInstanceTest)

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