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

The following examples show how to use com.taobao.weex.ui.component.WXVContainer#childCount() . 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: DOMActionContextImpl.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 * 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));
    }
  }
}
 
Example 2
Source File: WXDomStatement.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * 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));
    }
  }
}
 
Example 3
Source File: WXRenderStatement.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * 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));
    }
  }

}
 
Example 4
Source File: DomTracker.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
private int getComponentNumOfNode(@NonNull WXComponent rootNode) {
    Deque<WXComponent> deque = new ArrayDeque<>();
    deque.add(rootNode);
    int viewNum = 0;
    while (!deque.isEmpty()) {
        WXComponent node = deque.removeFirst();
        viewNum++;
        if (node instanceof WXVContainer) {
            WXVContainer container = (WXVContainer) node;
            for (int i = 0, count = container.childCount(); i < count; i++) {
                deque.add(container.getChild(i));
            }
        }
    }
    return viewNum;
}
 
Example 5
Source File: WXDomStatement.java    From weex with Apache License 2.0 6 votes vote down vote up
/**
 * 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.clone());
  if (component instanceof WXVContainer) {
    WXVContainer container = (WXVContainer) component;
    int count = container.childCount();
    for (int i = 0; i < count; ++i) {
      updateDomObj(container.getChild(i));
    }
  }
}
 
Example 6
Source File: WXRenderStatement.java    From weex with Apache License 2.0 6 votes vote down vote up
/**
 * Clear registry information that current instance contains.
 */
private void clearRegistryForComponent(WXComponent component) {
  WXComponent removedComponent = mRegistry.remove(component.getDomObject().ref);
  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));
    }
  }

}
 
Example 7
Source File: RemoveElementAction.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private void clearRegistryForComponent(RenderActionContext context, WXComponent component) {
  WXComponent removedComponent = context.unregisterComponent(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(context, container.getChild(i));
    }
  }

}
 
Example 8
Source File: BasicListComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Nullable
private WXComponent findComponentByAnchorName(@NonNull WXComponent root, @NonNull String anchorName) {
  long start = 0;
  if (WXEnvironment.isApkDebugable()) {
    start = System.currentTimeMillis();
  }

  Deque<WXComponent> deque = new ArrayDeque<>();
  deque.add(root);
  while (!deque.isEmpty()) {
    WXComponent curComponent = deque.removeFirst();
    ImmutableDomObject object = curComponent.getDomObject();
    if (object != null) {
      String isAnchorSet = WXUtils.getString(object.getAttrs().get(anchorName), null);

      //hit
      if (isAnchorSet != null && isAnchorSet.equals("true")) {
        if (WXEnvironment.isApkDebugable()) {
          WXLogUtils.d("dragPerf", "findComponentByAnchorName time: " + (System.currentTimeMillis() - start) + "ms");
        }
        return curComponent;
      }
    }
    if (curComponent instanceof WXVContainer) {
      WXVContainer container = (WXVContainer) curComponent;
      for (int i = 0, len = container.childCount(); i < len; i++) {
        WXComponent child = container.getChild(i);
        deque.add(child);
      }
    }
  }

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d("dragPerf", "findComponentByAnchorName elapsed time: " + (System.currentTimeMillis() - start) + "ms");
  }
  return null;

}