private void resolveIncludes(String resRoot, HashMap<Integer, String> nameMap,
                               HashMap<Integer, AndroidView> viewMap, boolean isSys) {
    HashMap<String, AndroidView> name2View = Maps.newHashMap();
    for (Map.Entry<Integer, String> entry : nameMap.entrySet()) {
      String name = entry.getValue();
      AndroidView view = viewMap.get(entry.getKey());
      name2View.put(name, view);
    }
//    boolean isSys = (viewMap == sysId2View);
    LinkedList<AndroidView> work = Lists.newLinkedList();
    work.addAll(viewMap.values());
    while (!work.isEmpty()) {
      AndroidView view = work.remove();
      for (int i = 0; i < view.getNumberOfChildren(); i++) {
        IAndroidView child = view.getChildInternal(i);
        if (child instanceof AndroidView) {
          work.add((AndroidView) child);
          continue;
        }
        IncludeAndroidView iav = (IncludeAndroidView) child;
        String layoutId = iav.layoutId;
        AndroidView tgt = name2View.get(layoutId);
        if (tgt != null) {
          tgt = (AndroidView) tgt.deepCopy();
          tgt.setParent(view, i);
        } else if (getLayoutFilePath(resRoot, layoutId, isSys) != null) {
          // not exist, let's get it on-demand
          String file = getLayoutFilePath(resRoot, layoutId, isSys);
          tgt = new AndroidView();
          tgt.setParent(view, i);
          tgt.setOrigin(file);
          readLayout(file, tgt, isSys);
          int newId = nonRId--;
          viewMap.put(newId, tgt);
          nameMap.put(newId, layoutId);
        } else if (sysRGeneralIdMap.get("layout").containsKey(layoutId) && sysId2View.containsKey
                (sysRGeneralIdMap.get("layout").get(layoutId)
                )) {
          // <include> is used with an in built android layout id
          tgt = (AndroidView) sysId2View.get(sysRGeneralIdMap.get("layout").get(layoutId)).deepCopy();
          tgt.setParent(view, i);
        } else {
          Logger.warn(this.getClass().getSimpleName(), "Unknown layout " + layoutId
                  + " included by " + view.getOrigin());
          continue;
        }
        Integer includeeId = iav.includeeId;
        if (includeeId != null) {
          tgt.setId(includeeId.intValue());
        }
        work.add(tgt);
      }
    }
  }
private void resolveIncludes(String resRoot, HashMap<Integer, String> nameMap,
                               HashMap<Integer, AndroidView> viewMap, boolean isSys) {
    HashMap<String, AndroidView> name2View = Maps.newHashMap();
    for (Map.Entry<Integer, String> entry : nameMap.entrySet()) {
      String name = entry.getValue();
      AndroidView view = viewMap.get(entry.getKey());
      name2View.put(name, view);
    }
    LinkedList<AndroidView> work = Lists.newLinkedList();
    work.addAll(viewMap.values());
    while (!work.isEmpty()) {
      AndroidView view = work.remove();
      for (int i = 0; i < view.getNumberOfChildren(); i++) {
        IAndroidView child = view.getChildInternal(i);
        if (child instanceof AndroidView) {
          work.add((AndroidView) child);
          continue;
        }
        IncludeAndroidView iav = (IncludeAndroidView) child;
        String layoutId = iav.layoutId;
        AndroidView tgt = name2View.get(layoutId);
        if (tgt != null) {
          tgt = (AndroidView) tgt.deepCopy();
          tgt.setParent(view, i);
        } else if (getLayoutFilePath(resRoot, layoutId, isSys) != null) {
         
          String file = getLayoutFilePath(resRoot, layoutId, isSys);
          tgt = new AndroidView();
          tgt.setParent(view, i);
          tgt.setOrigin(file);
          readLayout(file, tgt, isSys);
          int newId = nonRId--;
          viewMap.put(newId, tgt);
          nameMap.put(newId, layoutId);
        } else if (sysRGeneralIdMap.get("layout").containsKey(layoutId) && sysId2View.containsKey
                (sysRGeneralIdMap.get("layout").get(layoutId)
                )) {
         
          tgt = (AndroidView) sysId2View.get(sysRGeneralIdMap.get("layout").get(layoutId)).deepCopy();
          tgt.setParent(view, i);
        } else {
          Logger.warn(this.getClass().getSimpleName(), "Unknown layout " + layoutId
                  + " included by " + view.getOrigin());
          continue;
        }
        Integer includeeId = iav.includeeId;
        if (includeeId != null) {
          tgt.setId(includeeId.intValue());
        }
        work.add(tgt);
      }
    }
  }
private void resolveincludes(string resroot, hashmap<integer, string> namemap, hashmap<integer, androidview> viewmap, boolean issys) { hashmap<string, androidview> name2view = maps.newhashmap(); for (map.entry<integer, string> entry : namemap.entryset()) { string name = entry.getvalue(); androidview view = viewmap.get(entry.getkey()); name2view.put(name, view); } linkedlist<androidview> work = lists.newlinkedlist(); work.addall(viewmap.values()); while (!work.isempty()) { androidview view = work.remove(); for (int i = 0; i < view.getnumberofchildren(); i++) { iandroidview child = view.getchildinternal(i); if (child instanceof androidview) { work.add((androidview) child); continue; } includeandroidview iav = (includeandroidview) child; string layoutid = iav.layoutid; androidview tgt = name2view.get(layoutid); if (tgt != null) { tgt = (androidview) tgt.deepcopy(); tgt.setparent(view, i); } else if (getlayoutfilepath(resroot, layoutid, issys) != null) { string file = getlayoutfilepath(resroot, layoutid, issys); tgt = new androidview(); tgt.setparent(view, i); tgt.setorigin(file); readlayout(file, tgt, issys); int newid = nonrid--; viewmap.put(newid, tgt); namemap.put(newid, layoutid); } else if (sysrgeneralidmap.get("layout").containskey(layoutid) && sysid2view.containskey (sysrgeneralidmap.get("layout").get(layoutid) )) { tgt = (androidview) sysid2view.get(sysrgeneralidmap.get("layout").get(layoutid)).deepcopy(); tgt.setparent(view, i); } else { logger.warn(this.getclass().getsimplename(), "unknown layout " + layoutid + " included by " + view.getorigin()); continue; } integer includeeid = iav.includeeid; if (includeeid != null) { tgt.setid(includeeid.intvalue()); } work.add(tgt); } } }