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

The following examples show how to use com.taobao.weex.ui.component.WXVContainer#getChildCount() . 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: WXPageActivity.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param map <weexid,viewId>
 */
private static void collectId(WXComponent comp, Map<String,String> map){
  if(comp == null){
    return;
  }
  String id;
  View view;
  if((view = comp.getHostView())!=null &&
      (id = (String) comp.getAttrs().get("testId"))!=null &&
      !map.containsKey(id)){
    Pair<String,Integer> pair = Utility.nextID();
    view.setId(pair.second);
    map.put(id,pair.first);
  }
  if(comp instanceof WXVContainer){
    WXVContainer container = (WXVContainer) comp;
    for(int i = container.getChildCount()-1;i>=0;i--){
      collectId(container.getChild(i),map);
    }
  }
}
 
Example 2
Source File: ViewInspectorManager.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@Nullable
private WXComponent findBoundComponentBy(@NonNull View targetView,@NonNull WXComponent rootComponent) {
    Deque<WXComponent> deque = new ArrayDeque<>();
    deque.add(rootComponent);
    WXComponent targetComponent = null;

    while (!deque.isEmpty()) {
        WXComponent component = deque.removeFirst();

        View view = component.getHostView();
        if(view != null && view.equals(targetView)) {
            targetComponent = component;
        }

        //we should take embed into account
        if(component instanceof WXEmbed) {
            WXComponent nestedRootComponent = ViewUtils.getNestedRootComponent((WXEmbed) component);
            if(nestedRootComponent != null) {
                deque.add(nestedRootComponent);
            }
        } else if(component instanceof WXVContainer) {
            WXVContainer container = (WXVContainer) component;
            for(int i = 0,len = container.getChildCount(); i < len; i++) {
                WXComponent c = container.getChild(i);
                deque.add(c);
            }
        }
    }

    return targetComponent;
}