Search in sources :

Example 1 with WXTimerModule

use of com.taobao.weex.ui.module.WXTimerModule in project weex-example by KalicyZhou.

the class WXModuleManager method callModuleMethod.

static Object callModuleMethod(final String instanceId, String moduleStr, String methodStr, JSONArray args) {
    ModuleFactory factory = sModuleFactoryMap.get(moduleStr);
    if (factory == null) {
        WXLogUtils.e("[WXModuleManager] module factory not found.");
        return null;
    }
    final WXModule wxModule = findModule(instanceId, moduleStr, factory);
    if (wxModule == null) {
        return null;
    }
    WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId);
    wxModule.mWXSDKInstance = instance;
    final Invoker invoker = factory.getMethodInvoker(methodStr);
    try {
        return instance.getNativeInvokeHelper().invoke(wxModule, invoker, args);
    } catch (Exception e) {
        WXLogUtils.e("callModuleMethod >>> invoke module:" + moduleStr + ", method:" + methodStr + " failed. ", e);
        return null;
    } finally {
        if (wxModule instanceof WXDomModule || wxModule instanceof WXTimerModule) {
            wxModule.mWXSDKInstance = null;
        }
    }
}
Also used : WXDomModule(com.taobao.weex.dom.WXDomModule) WXSDKInstance(com.taobao.weex.WXSDKInstance) WXTimerModule(com.taobao.weex.ui.module.WXTimerModule) WXModule(com.taobao.weex.common.WXModule) WXException(com.taobao.weex.common.WXException)

Aggregations

WXSDKInstance (com.taobao.weex.WXSDKInstance)1 WXException (com.taobao.weex.common.WXException)1 WXModule (com.taobao.weex.common.WXModule)1 WXDomModule (com.taobao.weex.dom.WXDomModule)1 WXTimerModule (com.taobao.weex.ui.module.WXTimerModule)1