com.taobao.weex.dom.WXDomModule Java Examples
The following examples show how to use
com.taobao.weex.dom.WXDomModule.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 6 votes |
public Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNativeComponent >>>> instanceId:").append(instanceId) .append(", componentRef:").append(componentRef).append(", method:").append(method).append(", arguments:").append(arguments); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } try { WXDomModule dom = getDomModule(instanceId); dom.invokeMethod(componentRef, method, arguments); } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callNative exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE, "[WXBridgeManager] callNativeModule exception " + e.getCause()); } return null; }
Example #2
Source File: WXSDKEngine.java From weex with Apache License 2.0 | 6 votes |
private static void register() { try { registerComponent(WXBasicComponentType.TEXT, WXText.class, false); registerComponent(WXBasicComponentType.IMG, WXImage.class, false); registerComponent(WXBasicComponentType.DIV, WXDiv.class, false); registerComponent(WXBasicComponentType.IMAGE, WXImage.class, false); registerComponent(WXBasicComponentType.CONTAINER, WXDiv.class, false); registerComponent(WXBasicComponentType.SCROLLER, WXScroller.class, false); registerComponent(WXBasicComponentType.SLIDER, WXSlider.class, true); registerComponent(WXListComponent.class, false,WXBasicComponentType.LIST,WXBasicComponentType.VLIST); registerComponent(HorizontalListComponent.class,false,WXBasicComponentType.HLIST); registerComponent(WXBasicComponentType.CELL, WXCell.class, true); registerComponent(WXBasicComponentType.INDICATOR, WXIndicator.class, true); registerComponent(WXBasicComponentType.VIDEO, WXVideo.class, false); registerComponent(WXBasicComponentType.INPUT, WXInput.class, false); registerComponent(WXBasicComponentType.SWITCH, WXSwitch.class, false); registerComponent(WXBasicComponentType.A, WXA.class, false); registerComponent(WXBasicComponentType.EMBED, WXEmbed.class, true); registerComponent(WXBasicComponentType.WEB, WXWeb.class); registerComponent(WXBasicComponentType.REFRESH, WXRefresh.class); registerComponent(WXBasicComponentType.LOADING, WXLoading.class); registerComponent(WXBasicComponentType.LOADING_INDICATOR, WXLoadingIndicator.class); registerModule("dom", WXDomModule.class, true); registerModule("modal", WXModalUIModule.class, false); registerModule("instanceWrap", WXInstanceWrap.class, true); registerModule("animation", WXAnimationModule.class, true); registerModule("webview", WXWebViewModule.class, true); registerModule("navigator", WXNavigatorModule.class); registerModule("stream", WXStreamModule.class); registerDomObject(WXBasicComponentType.TEXT, WXTextDomObject.class); registerDomObject(WXBasicComponentType.INPUT, WXTextDomObject.class); registerDomObject(WXBasicComponentType.SWITCH, WXSwitchDomObject.class); } catch (WXException e) { WXLogUtils.e("[WXSDKEngine] register:" + WXLogUtils.getStackTrace(e)); } }
Example #3
Source File: WXBridgeManager.java From weex-uikit with MIT License | 6 votes |
public Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNativeComponent >>>> instanceId:").append(instanceId) .append(", componentRef:").append(componentRef).append(", method:").append(method).append(", arguments:").append(arguments); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } try { WXDomModule dom = getDomModule(instanceId); dom.invokeMethod(componentRef, method, arguments); } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callNative exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE, "[WXBridgeManager] callNativeModule exception " + e.getCause()); } return null; }
Example #4
Source File: WXBridgeManager.java From weex-uikit with MIT License | 6 votes |
public Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNativeModule >>>> instanceId:").append(instanceId) .append(", module:").append(module).append(", method:").append(method).append(", arguments:").append(arguments); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } try { if(WXDomModule.WXDOM.equals(module)){ WXDomModule dom = getDomModule(instanceId); return dom.callDomMethod(method,arguments); }else { return WXModuleManager.callModuleMethod(instanceId, module, method, arguments); } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callNative exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE, "[WXBridgeManager] callNativeModule exception " + e.getCause()); } return null; }
Example #5
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 6 votes |
public Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNativeModule >>>> instanceId:").append(instanceId) .append(", module:").append(module).append(", method:").append(method).append(", arguments:").append(arguments); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } try { if(WXDomModule.WXDOM.equals(module)){ WXDomModule dom = getDomModule(instanceId); return dom.callDomMethod(method,arguments); }else { return callModuleMethod(instanceId, module, method, arguments); } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callNative exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE, "[WXBridgeManager] callNativeModule exception " + e.getCause()); } return null; }
Example #6
Source File: WXBridgeManagerTest.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Test public void testCallNative() throws Exception { getInstance() .callNative(instance.getInstanceId(), "[{\"module\":\"testModule\",\"method\":\"test\"}]", null); getInstance() .callNative(instance.getInstanceId(), "[{\"module\":\""+WXDomModule.WXDOM+"\",\"method\":\"test\"}]", null); }
Example #7
Source File: WXBridgeManagerTest.java From weex-uikit with MIT License | 5 votes |
@Test public void testCallNative() throws Exception { getInstance() .callNative(instance.getInstanceId(), "[{\"module\":\"testModule\",\"method\":\"test\"}]", null); getInstance() .callNative(instance.getInstanceId(), "[{\"module\":\""+WXDomModule.WXDOM+"\",\"method\":\"test\"}]", null); }
Example #8
Source File: WXBridgeManager.java From weex-uikit with MIT License | 5 votes |
public int callAddElement(String instanceId, String ref,String dom,String index, String callback){ if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNative::callAddElement >>>> instanceId:").append(instanceId) .append(", ref:").append(ref).append(", dom:").append(dom).append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId!=null && mDestroyedInstanceId.contains(instanceId)){ return IWXBridge.DESTROY_INSTANCE; } if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { long start = System.currentTimeMillis(); JSONObject domObject = JSON.parseObject(dom); if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { WXSDKManager.getInstance().getSDKInstance(instanceId).jsonParseTime(System.currentTimeMillis() - start); } WXDomModule domModule = getDomModule(instanceId); domModule.addElement(ref, domObject, Integer.parseInt(index)); } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } // get next tick getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; }
Example #9
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public int callUpdateFinish(String instanceId, String callback) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callUpdateFinish >>>> instanceId:").append(instanceId) .append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId != null && mDestroyedInstanceId.contains(instanceId)){ return IWXBridge.DESTROY_INSTANCE; } try { if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { WXDomModule domModule = getDomModule(instanceId); Action action = Actions.getUpdateFinish(); domModule.postAction((DOMAction)action, false); } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callUpdateFinish exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callUpdateFinish exception "+e.getCause()); } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } // get next tick getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; }
Example #10
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public int callCreateFinish(String instanceId, String callback) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callCreateFinish >>>> instanceId:").append(instanceId) .append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId != null && mDestroyedInstanceId.contains(instanceId)) { return IWXBridge.DESTROY_INSTANCE; } try { if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { WXDomModule domModule = getDomModule(instanceId); Action action = Actions.getCreateFinish(); domModule.postAction((DOMAction)action, false); } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callCreateFinish exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERROR_DOM_CREATEFINISH,"[WXBridgeManager] callCreateFinish exception " + e.getCause()); } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } // get next tick getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; }
Example #11
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public int callRefreshFinish(String instanceId, String callback) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callRefreshFinish >>>> instanceId:").append(instanceId) .append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId != null && mDestroyedInstanceId.contains(instanceId)) { return IWXBridge.DESTROY_INSTANCE; } try { if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { WXDomModule domModule = getDomModule(instanceId); Action action = Actions.getRefreshFinish(); domModule.postAction((DOMAction)action, false); } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callRefreshFinish exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERROR_DOM_REFRESHFINISH,"[WXBridgeManager] callRefreshFinish exception " + e.getCause()); } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } // get next tick getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; }
Example #12
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public int callAddElement(String instanceId, String ref,String dom,String index, String callback){ if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNative::callAddElement >>>> instanceId:").append(instanceId) .append(", ref:").append(ref).append(", dom:").append(dom).append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId!=null && mDestroyedInstanceId.contains(instanceId)){ return IWXBridge.DESTROY_INSTANCE; } if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { long start = System.currentTimeMillis(); JSONObject domObject = JSON.parseObject(dom); if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { WXSDKManager.getInstance().getSDKInstance(instanceId).jsonParseTime(System.currentTimeMillis() - start); } WXDomModule domModule = getDomModule(instanceId); domModule.postAction(Actions.getAddElement(domObject, ref,Integer.parseInt(index)),false); } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } // get next tick getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; }
Example #13
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public int callRemoveEvent(String instanceId, String ref, String event, String callback) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callRemoveEvent >>>> instanceId:").append(instanceId) .append(", ref:").append(ref) .append(", event:").append(event); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId != null && mDestroyedInstanceId.contains(instanceId)) { return IWXBridge .DESTROY_INSTANCE; } try { if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { WXDomModule domModule = getDomModule(instanceId); Action action = Actions.getRemoveEvent(ref, event); domModule.postAction((DOMAction)action, false); } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callRemoveEvent exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_DOM_REMOVEEVENT,"[WXBridgeManager] callRemoveEvent exception " + e.getCause()); } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } // get next tick getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; }
Example #14
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public int callAddEvent(String instanceId, String ref, String event, String callback) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callAddEvent >>>> instanceId:").append(instanceId) .append(", ref:").append(ref) .append(", event:").append(event); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId != null && mDestroyedInstanceId.contains(instanceId)) { return IWXBridge.DESTROY_INSTANCE; } try { if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { WXDomModule domModule = getDomModule(instanceId); Action action = Actions.getAddEvent(ref, event); domModule.postAction((DOMAction)action, false); } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callAddEvent exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_DOM_ADDEVENT,"[WXBridgeManager] callAddEvent exception " + e.getCause()); } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } // get next tick getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; }
Example #15
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public int callMoveElement(String instanceId, String ref, String parentref, String index, String callback) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callMoveElement >>>> instanceId:").append(instanceId) .append(", parentref:").append(parentref) .append(", index:").append(index) .append(", ref:").append(ref); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId != null && mDestroyedInstanceId.contains(instanceId)) { return IWXBridge.DESTROY_INSTANCE; } try { if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { WXDomModule domModule = getDomModule(instanceId); Action action = Actions.getMoveElement(ref, parentref, Integer.parseInt(index)); domModule.postAction((DOMAction)action, false); } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callMoveElement exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_DOM_MOVEELEMENT,"[WXBridgeManager] callMoveElement exception " + e.getCause()); } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } // get next tick getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; }
Example #16
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public int callRemoveElement(String instanceId, String ref, String callback) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callRemoveElement >>>> instanceId:").append(instanceId) .append(", ref:").append(ref); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId != null && mDestroyedInstanceId.contains(instanceId)) { return IWXBridge.DESTROY_INSTANCE; } try { if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { WXDomModule domModule = getDomModule(instanceId); Action action = Actions.getRemoveElement(ref); domModule.postAction((DOMAction)action, false); } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callRemoveElement exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT,"[WXBridgeManager] callRemoveElement exception " + e.getCause()); } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } // get next tick getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; }
Example #17
Source File: WXModuleManager.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public static void createDomModule(WXSDKInstance instance){ if(instance != null) { sDomModuleMap.put(instance.getInstanceId(), new WXDomModule(instance)); } }
Example #18
Source File: WXModuleManager.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public static WXDomModule getDomModule(String instanceId){ return sDomModuleMap.get(instanceId); }
Example #19
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 4 votes |
private void registerDomModule() throws WXException { /** Tell Javascript Framework what methods you have. This is Required.**/ Map<String,Object> domMap=new HashMap<>(); domMap.put(WXDomModule.WXDOM,WXDomModule.METHODS); registerModules(domMap); }
Example #20
Source File: WXBridgeManager.java From weex-uikit with MIT License | 4 votes |
private void registerDomModule() throws WXException { /** Tell Javascript Framework what methods you have. This is Required.**/ Map<String,Object> domMap=new HashMap<>(); domMap.put(WXDomModule.WXDOM,WXDomModule.METHODS); registerModules(domMap); }
Example #21
Source File: WXModuleManager.java From weex-uikit with MIT License | 4 votes |
public static void createDomModule(WXSDKInstance instance){ if(instance != null) { sDomModuleMap.put(instance.getInstanceId(), new WXDomModule(instance)); } }
Example #22
Source File: WXModuleManager.java From weex-uikit with MIT License | 4 votes |
public static WXDomModule getDomModule(String instanceId){ return sDomModuleMap.get(instanceId); }