@Test public void testParseFromJson() throws Exception { dom.parseFromJson(JSONObject.parseObject("{\"ref\":\"100\",\"type\":\"div\",\"attr\":{},\"style\":{\"backgroundColor\":\"rgb(40,96,144)\",\"fontSize\":40,\"color\":\"#ffffff\",\"paddingRight\":30,\"paddingLeft\":30,\"paddingBottom\":20,\"paddingTop\":20}}")); assertEquals(dom.getRef(),"100"); assertEquals(dom.getType(),"div"); dom.applyStyleToNode(); }
public void parseFromJson(JSONObject map){ if (map == null || map.size() <= 0) { return; } String type = (String) map.get("type"); this.mType = type; this.mRef = (String) map.get("ref"); Object style = map.get("style"); if (style != null && style instanceof JSONObject) { WXStyle styles = new WXStyle(); styles.putAll((JSONObject) style,false); this.mStyles = styles; } Object attr = map.get("attr"); if (attr != null && attr instanceof JSONObject) { WXAttr attrs = new WXAttr((JSONObject) attr); this.mAttributes = attrs; } Object event = map.get("event"); if (event != null && event instanceof JSONArray) { WXEvent events = new WXEvent(); JSONArray eventArray = (JSONArray) event; int count = eventArray.size(); for (int i = 0; i < count; ++i) { events.add(eventArray.getString(i)); } this.mEvents = events; } }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void parseFromJson(JSONObject map){ if (map == null || map.size() <= 0) { return; } String type = (String) map.get("type"); this.mType = type; this.mRef = (String) map.get("ref"); Object style = map.get("style"); if (style != null && style instanceof JSONObject) { WXStyle styles = new WXStyle(); styles.putAll((JSONObject) style,false); this.mStyles = styles; } Object attr = map.get("attr"); if (attr != null && attr instanceof JSONObject) { WXAttr attrs = new WXAttr((JSONObject) attr); this.mAttributes = attrs; } Object event = map.get("event"); if (event != null && event instanceof JSONArray) { WXEvent events = new WXEvent(); JSONArray eventArray = (JSONArray) event; int count = eventArray.size(); for (int i = 0; i < count; ++i) { events.add(eventArray.getString(i)); } this.mEvents = events; } } }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void parseFromJson(JSONObject map){ if (map == null || map.size() <= 0) { return; } String type = (String) map.get("type"); this.mType = type; this.mRef = (String) map.get("ref"); Object style = map.get("style"); if (style != null && style instanceof JSONObject) { WXStyle styles = new WXStyle(); styles.putAll((JSONObject) style,false); this.mStyles = styles; } Object attr = map.get("attr"); if (attr != null && attr instanceof JSONObject) { WXAttr attrs = new WXAttr((JSONObject) attr); this.mAttributes = attrs; } Object event = map.get("event"); if (event != null && event instanceof JSONArray) { WXEvent events = new WXEvent(); JSONArray eventArray = (JSONArray) event; int count = eventArray.size(); for (int i = 0; i < count; ++i) { events.add(eventArray.getString(i)); } this.mEvents = events; } }  }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void parseFromJson(JSONObject map){ if (map == null || map.size() <= 0) { return; } String type = (String) map.get("type"); this.mType = type; this.mRef = (String) map.get("ref"); Object style = map.get("style"); if (style != null && style instanceof JSONObject) { WXStyle styles = new WXStyle(); styles.putAll((JSONObject) style,false); this.mStyles = styles; } Object attr = map.get("attr"); if (attr != null && attr instanceof JSONObject) { WXAttr attrs = new WXAttr((JSONObject) attr); this.mAttributes = attrs; } Object event = map.get("event"); if (event != null && event instanceof JSONArray) { WXEvent events = new WXEvent(); JSONArray eventArray = (JSONArray) event; int count = eventArray.size(); for (int i = 0; i < count; ++i) { events.add(eventArray.getString(i)); } this.mEvents = events; } }  int getViewPortWidth(); void setViewPortWidth(int mViewPortWidth); String getRef(); String getType(); @NonNull WXStyle getStyles(); @NonNull WXAttr getAttrs(); @NonNull WXEvent getEvents(); @NonNull DomContext getDomContext(); void clearEvents(); static void prepareRoot(WXDomObject domObj,float defaultHeight,float defaultWidth); void parseFromJson(JSONObject map); void layoutBefore(); void layoutAfter(); final boolean hasUpdate(); final void markUpdateSeen(); boolean isFixed(); Object getExtra(); void remove(WXDomObject child); void removeFromDom(WXDomObject child); int index(WXDomObject child); void add(WXDomObject child, int index); @Deprecated void add2Dom(WXDomObject child, int index); WXDomObject getChild(int index); void addEvent(String e); boolean containsEvent(String e); void removeEvent(String e); void updateAttr(Map<String, Object> attrs); void updateStyle(Map<String, Object> styles); void updateStyle(Map<String, Object> styles, boolean byPesudo); int childCount(); void hide(); void show(); boolean isVisible(); @Override WXDomObject clone(); void destroy(); ArrayList<String> getFixedStyleRefs(); void add2FixedDomList(String ref); String dumpDomTree(); static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance); }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void parseFromJson(JSONObject map){ if (map == null || map.size() <= 0) { return; } String type = (String) map.get("type"); this.mType = type; this.mRef = (String) map.get("ref"); Object style = map.get("style"); if (style != null && style instanceof JSONObject) { WXStyle styles = new WXStyle(); styles.putAll((JSONObject) style,false); this.mStyles = styles; } Object attr = map.get("attr"); if (attr != null && attr instanceof JSONObject) { WXAttr attrs = new WXAttr((JSONObject) attr); this.mAttributes = attrs; } Object event = map.get("event"); if (event != null && event instanceof JSONArray) { WXEvent events = new WXEvent(); JSONArray eventArray = (JSONArray) event; int count = eventArray.size(); for (int i = 0; i < count; ++i) { events.add(eventArray.getString(i)); } this.mEvents = events; } }  int getViewPortWidth(); void setViewPortWidth(int mViewPortWidth); String getRef(); String getType(); @NonNull WXStyle getStyles(); @NonNull WXAttr getAttrs(); @NonNull WXEvent getEvents(); @NonNull DomContext getDomContext(); void clearEvents(); static void prepareRoot(WXDomObject domObj,float defaultHeight,float defaultWidth); void parseFromJson(JSONObject map); void layoutBefore(); void layoutAfter(); final boolean hasUpdate(); final void markUpdateSeen(); boolean isFixed(); Object getExtra(); void remove(WXDomObject child); void removeFromDom(WXDomObject child); int index(WXDomObject child); void add(WXDomObject child, int index); @Deprecated void add2Dom(WXDomObject child, int index); WXDomObject getChild(int index); void addEvent(String e); boolean containsEvent(String e); void removeEvent(String e); void updateAttr(Map<String, Object> attrs); void updateStyle(Map<String, Object> styles); void updateStyle(Map<String, Object> styles, boolean byPesudo); int childCount(); void hide(); void show(); boolean isVisible(); @Override WXDomObject clone(); void destroy(); ArrayList<String> getFixedStyleRefs(); void add2FixedDomList(String ref); String dumpDomTree(); static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance); static final String CHILDREN; static final String TYPE; static final String TAG; static final String ROOT; static final String TRANSFORM; static final String TRANSFORM_ORIGIN; @Deprecated
  public WXDomObject parent; }