Exemplo n.º 1
0
  public void rebuildCommentGroups() {

    commentGroups = new ArrayList<CommentGroup>();
    Comment prevComment = null;
    for (Comment comment : comments) {
      if (prevComment != null) {

        CommentGroup group = new CommentGroup();
        group.setDateString(comment.getDate());

        if (commentGroups.contains(group)) {

          int index = commentGroups.indexOf(group);
          group = commentGroups.get(index);
          group.addComment(comment);

        } else {
          addNewCommentGroup(comment);
        }

      } else {
        addNewCommentGroup(comment);
      }
      prevComment = comment;
    }
  }
Exemplo n.º 2
0
 private void addNewCommentGroup(Comment comment) {
   CommentGroup group = new CommentGroup();
   group.setDateString(comment.getDate());
   List<Comment> groupComments = new ArrayList<Comment>();
   groupComments.add(comment);
   group.setComments(groupComments);
   commentGroups.add(group);
 }