示例#1
0
    private void add(final TreeEntry entry) {
      String type = entry.getType();
      String path = entry.getPath();
      if (TextUtils.isEmpty(path)) return;

      if (TYPE_BLOB.equals(type)) {
        String[] segments = path.split("/");
        if (segments.length > 1) {
          Folder folder = folders.get(segments[0]);
          if (folder != null) folder.addFile(entry, segments, 1);
        } else if (segments.length == 1) {
          Entry file = new Entry(entry, this);
          files.put(file.name, file);
        }
      } else if (TYPE_TREE.equals(type)) {
        String[] segments = path.split("/");
        if (segments.length > 1) {
          Folder folder = folders.get(segments[0]);
          if (folder != null) folder.addFolder(entry, segments, 1);
        } else if (segments.length == 1) {
          Folder folder = new Folder(entry, this);
          folders.put(folder.name, folder);
        }
      }
    }
示例#2
0
 private Entry(TreeEntry entry, Folder parent) {
   this.entry = entry;
   this.parent = parent;
   this.name = CommitUtils.getName(entry.getPath());
 }