@Test public void testAdd() throws Exception { JSONObject obj = new JSONObject(); obj.put("ref","100"); obj.put("type","div"); dom.parseFromJson(obj); JSONObject child = new JSONObject(); child.put("ref","101"); child.put("type","test"); WXDomObject childDom = new WXDomObject(); childDom.parseFromJson(child); dom.add(childDom,0); assertEquals(dom.getChildCount(),1); assertEquals(dom.getChild(0),childDom); dom.removeChildAt(0); assertEquals(dom.getChildCount(),0); dom.add(childDom,0); assertEquals(dom.getChildCount(),1); assertEquals(dom.getChild(0),childDom); dom.remove(childDom); }
public void add(WXDomObject child, int index) { if (child == null || index < -1 || sDestroy.get()) { return; } if (mDomChildren == null) { mDomChildren = new ArrayList<>(); } int count = mDomChildren.size(); index = index >= count ? -1 : index; if (index == -1) { mDomChildren.add(child); super.addChildAt(child, super.getChildCount()); } else { mDomChildren.add(index, child); super.addChildAt(child, index); } child.parent = this; }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void add(WXDomObject child, int index) { if (child == null || index < -1 || sDestroy.get()) { return; } if (mDomChildren == null) { mDomChildren = new ArrayList<>(); } int count = mDomChildren.size(); index = index >= count ? -1 : index; if (index == -1) { mDomChildren.add(child); super.addChildAt(child, super.getChildCount()); } else { mDomChildren.add(index, child); super.addChildAt(child, index); } child.parent = this; } }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void add(WXDomObject child, int index) { if (child == null || index < -1 || sDestroy.get()) { return; } if (mDomChildren == null) { mDomChildren = new ArrayList<>(); } int count = mDomChildren.size(); index = index >= count ? -1 : index; if (index == -1) { mDomChildren.add(child); super.addChildAt(child, super.getChildCount()); } else { mDomChildren.add(index, child); super.addChildAt(child, index); } child.parent = this; }  }
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void add(WXDomObject child, int index) { if (child == null || index < -1 || sDestroy.get()) { return; } if (mDomChildren == null) { mDomChildren = new ArrayList<>(); } int count = mDomChildren.size(); index = index >= count ? -1 : index; if (index == -1) { mDomChildren.add(child); super.addChildAt(child, super.getChildCount()); } else { mDomChildren.add(index, child); super.addChildAt(child, index); } child.parent = this; }  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 add(WXDomObject child, int index) { if (child == null || index < -1 || sDestroy.get()) { return; } if (mDomChildren == null) { mDomChildren = new ArrayList<>(); } int count = mDomChildren.size(); index = index >= count ? -1 : index; if (index == -1) { mDomChildren.add(child); super.addChildAt(child, super.getChildCount()); } else { mDomChildren.add(index, child); super.addChildAt(child, index); } child.parent = this; }  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; }