Java Code Examples for com.taobao.weex.ui.component.WXVContainer#addChild()

The following examples show how to use com.taobao.weex.ui.component.WXVContainer#addChild() . 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: AbstractAddElementAction.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
protected WXComponent generateComponentTree(DOMActionContext context, WXDomObject dom, WXVContainer parent) {
  if (dom == null) {
    return null;
  }
  WXComponent component = WXComponentFactory.newInstance(context.getInstance(), dom, parent);

  context.registerComponent(dom.getRef(), component);
  if (component instanceof WXVContainer) {
    WXVContainer parentC = (WXVContainer) component;
    int count = dom.childCount();
    WXDomObject child = null;
    for (int i = 0; i < count; ++i) {
      child = dom.getChild(i);
      if (child != null) {
        parentC.addChild(generateComponentTree(context, child, parentC));
      }
    }
  }

  return component;
}
 
Example 2
Source File: WXRenderStatement.java    From weex-uikit with MIT License 6 votes vote down vote up
private WXComponent generateComponentTree(WXDomObject dom, WXVContainer parent) {
  if (dom == null ) {
    return null;
  }
  WXComponent component = WXComponentFactory.newInstance(mWXSDKInstance, dom,parent);

  mRegistry.put(dom.getRef(), component);
  if (component instanceof WXVContainer) {
    WXVContainer parentC = (WXVContainer) component;
    int count = dom.childCount();
    WXDomObject child = null;
    for (int i = 0; i < count; ++i) {
      child = dom.getChild(i);
      if (child != null) {
        parentC.addChild(generateComponentTree(child, parentC));
      }
    }
  }

  return component;
}
 
Example 3
Source File: WXRenderStatement.java    From weex with Apache License 2.0 6 votes vote down vote up
WXComponent createBodyOnDomThread(WXDomObject dom) {
  if (mWXSDKInstance == null) {
    return null;
  }
  WXDomObject domObject = new WXDomObject();
  domObject.type = WXBasicComponentType.DIV;
  domObject.ref = "god";
  mGodComponent = (WXVContainer) WXComponentFactory.newInstance(mWXSDKInstance, domObject, null);
  mGodComponent.createView(null, -1);
  if (mGodComponent == null) {
    if (WXEnvironment.isApkDebugable()) {
      WXLogUtils.e("rootView failed!");
    }
    //TODO error callback
    return null;
  }
  FrameLayout frameLayout = (FrameLayout) mGodComponent.getView();
  ViewGroup.LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  frameLayout.setLayoutParams(layoutParams);
  frameLayout.setBackgroundColor(Color.TRANSPARENT);

  WXComponent component = generateComponentTree(dom, mGodComponent);
  mGodComponent.addChild(component);
  mRegistry.put(component.getRef(), component);
  return component;
}
 
Example 4
Source File: WXRenderStatement.java    From weex with Apache License 2.0 6 votes vote down vote up
private WXComponent generateComponentTree(WXDomObject dom, WXVContainer parent) {
  if (dom == null || parent == null) {
    return null;
  }
  WXComponent component = WXComponentFactory.newInstance(mWXSDKInstance, dom,
                                                         parent, parent.isLazy());

  mRegistry.put(dom.ref, component);
  if (component instanceof WXVContainer) {
    WXVContainer parentC = (WXVContainer) component;
    int count = dom.childCount();
    WXDomObject child = null;
    for (int i = 0; i < count; ++i) {
      child = dom.getChild(i);
      if (child != null) {
        parentC.addChild(generateComponentTree(child, parentC));
      }
    }
  }

  return component;
}
 
Example 5
Source File: WXSDKInstanceTest.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public static void setupRoot(WXSDKInstance instance){

    WXDomObject domObject = new WXDomObject();
    WXVContainer comp = (WXVContainer) WXComponentFactory.newInstance(instance, domObject, null);

    WXComponent root = WXDivTest.create(comp);
    comp.addChild(root);
    comp.createView();

    instance.onCreateFinish();
    ShadowLooper.idleMainLooper();
  }
 
Example 6
Source File: WXRenderStatement.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * @see com.taobao.weex.dom.WXDomStatement#addDom(JSONObject, String, int)
 */
void addComponent(WXComponent component, String parentRef, int index) {
  WXVContainer parent = (WXVContainer) mRegistry.get(parentRef);
  if (parent == null || component == null) {
    return;
  }

  parent.addChild(component, index);
  parent.createChildViewAt(index);
  component.applyLayoutAndEvent(component);
  component.bindData(component);
}
 
Example 7
Source File: WXRenderStatement.java    From weex with Apache License 2.0 5 votes vote down vote up
/**
 * @see com.taobao.weex.dom.WXDomStatement#addDom(JSONObject, String, int)
 */
void addComponent(WXDomObject dom, String parentRef, int index) {
  WXVContainer parent = (WXVContainer) mRegistry.get(parentRef);
  WXComponent component = generateComponentTree(dom, parent);
  parent.addChild(component, index);
  WXAnimationModule.applyTransformStyle(dom.style, component);
}
 
Example 8
Source File: WXRenderStatement.java    From weex with Apache License 2.0 5 votes vote down vote up
/**
 * @see com.taobao.weex.dom.WXDomStatement#addDom(JSONObject, String, int)
 */
void addComponent(WXComponent component, String parentRef, int index) {
  WXVContainer parent = (WXVContainer) mRegistry.get(parentRef);
  if (parent == null || component == null) {
    return;
  }
  component.createView(parent, index);
  component.applyLayoutAndEvent(component);
  component.bindData(component);
  parent.addChild(component, index);
  WXAnimationModule.applyTransformStyle(component.mDomObj.style, component);
}
 
Example 9
Source File: WXRenderStatement.java    From weex-uikit with MIT License 4 votes vote down vote up
/**
 * @see com.taobao.weex.dom.WXDomStatement#addDom(JSONObject, String, int)
 */
void addComponent(WXDomObject dom, String parentRef, int index) {
  WXVContainer parent = (WXVContainer) mRegistry.get(parentRef);
  WXComponent component = generateComponentTree(dom, parent);
  parent.addChild(component, index);
}