Search in sources :

Example 1 with WXVContainer

use of com.taobao.weex.ui.component.WXVContainer in project weex-example by KalicyZhou.

the class WXDomStatement method updateDomObj.

/**
   * Update the specified component's dom and mark it as old.
   * @param component the component to be updated
   */
private void updateDomObj(WXComponent component) {
    if (component == null) {
        return;
    }
    WXDomObject domObject = mRegistry.get(component.getRef());
    if (domObject == null) {
        return;
    }
    domObject.old();
    component.updateDom(domObject);
    if (component instanceof WXVContainer) {
        WXVContainer container = (WXVContainer) component;
        int count = container.childCount();
        for (int i = 0; i < count; ++i) {
            updateDomObj(container.getChild(i));
        }
    }
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer)

Example 2 with WXVContainer

use of com.taobao.weex.ui.component.WXVContainer in project weex-example by KalicyZhou.

the class WXRenderStatement method addComponent.

/**
   * @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);
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer)

Example 3 with WXVContainer

use of com.taobao.weex.ui.component.WXVContainer in project weex-example by KalicyZhou.

the class WXRenderStatement method removeComponent.

/**
   *@see com.taobao.weex.dom.WXDomStatement#removeDom(String)
   */
WXComponent removeComponent(String ref) {
    WXComponent component = mRegistry.get(ref);
    if (component == null || component.getParent() == null) {
        return component;
    }
    WXVContainer parent = component.getParent();
    clearRegistryForComponent(component);
    parent.remove(component, true);
    mRegistry.remove(ref);
    return component;
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 4 with WXVContainer

use of com.taobao.weex.ui.component.WXVContainer in project weex-example by KalicyZhou.

the class WXRenderStatement method clearRegistryForComponent.

/**
   * Clear registry information that current instance contains.
   */
private void clearRegistryForComponent(WXComponent component) {
    WXComponent removedComponent = mRegistry.remove(component.getDomObject().getRef());
    if (removedComponent != null) {
        removedComponent.removeAllEvent();
        removedComponent.removeStickyStyle();
    }
    if (component instanceof WXVContainer) {
        WXVContainer container = (WXVContainer) component;
        int count = container.childCount();
        for (int i = count - 1; i >= 0; --i) {
            clearRegistryForComponent(container.getChild(i));
        }
    }
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXComponent(com.taobao.weex.ui.component.WXComponent)

Example 5 with WXVContainer

use of com.taobao.weex.ui.component.WXVContainer in project weex-example by KalicyZhou.

the class WXRenderStatement method generateComponentTree.

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;
}
Also used : WXVContainer(com.taobao.weex.ui.component.WXVContainer) WXComponent(com.taobao.weex.ui.component.WXComponent) WXDomObject(com.taobao.weex.dom.WXDomObject)

Aggregations

WXVContainer (com.taobao.weex.ui.component.WXVContainer)7 WXComponent (com.taobao.weex.ui.component.WXComponent)5 WXDomObject (com.taobao.weex.dom.WXDomObject)1