use of com.winsonchiu.reader.data.reddit.Comment in project Reader by TheKeeperOfPie.
the class ControllerComments method reloadAllComments.
public void reloadAllComments() {
if (TextUtils.isEmpty(link.getId())) {
setLoading(false);
return;
}
if (link.getContextLevel() > 0 && !TextUtils.isEmpty(link.getCommentId())) {
loadCommentThread();
return;
}
if (!link.getComments().getChildren().isEmpty()) {
Comment commentFirst = ((Comment) link.getComments().getChildren().get(0));
if (!commentFirst.getParentId().equals(link.getId())) {
link.setCommentId(commentFirst.getId());
loadCommentThread();
return;
}
}
loadLinkComments();
}
use of com.winsonchiu.reader.data.reddit.Comment in project Reader by TheKeeperOfPie.
the class ControllerComments method insertComment.
public void insertComment(Comment comment) {
// Check to see if comment is actually a part of the link's comment thread
if (!comment.getLinkId().equals(link.getName())) {
return;
}
Comment parentComment = new Comment();
parentComment.setId(comment.getParentId());
int commentIndex;
if (link.getComments() != null) {
commentIndex = link.getComments().getChildren().indexOf(parentComment);
if (commentIndex > -1) {
parentComment = (Comment) link.getComments().getChildren().get(commentIndex);
comment.setLevel(parentComment.getLevel() + 1);
}
link.getComments().getChildren().add(commentIndex + 1, comment);
}
if (listingComments != null) {
commentIndex = listingComments.getChildren().indexOf(parentComment);
if (commentIndex > -1) {
parentComment = (Comment) listingComments.getChildren().get(commentIndex);
comment.setLevel(parentComment.getLevel() + 1);
}
listingComments.getChildren().add(commentIndex + 1, comment);
eventHolder.call(new RxAdapterEvent<>(getData(), RxAdapterEvent.Type.INSERT, commentIndex + 2));
}
}
use of com.winsonchiu.reader.data.reddit.Comment in project Reader by TheKeeperOfPie.
the class ControllerProfile method insertComment.
public void insertComment(Comment comment) {
// Placeholder to use ArrayList.indexOfLink() properly
Comment parentComment = new Comment();
parentComment.setId(comment.getParentId());
int commentIndex = data.getChildren().indexOf(parentComment);
if (commentIndex > -1) {
// Level and context are set as they are not provided by the send API
parentComment = (Comment) data.getChildren().get(commentIndex);
comment.setLevel(parentComment.getLevel() + 1);
comment.setContext(parentComment.getContext());
data.getChildren().add(commentIndex + 1, comment);
for (Listener listener : listeners) {
listener.getAdapter().notifyItemInserted(commentIndex + 7);
}
}
}
use of com.winsonchiu.reader.data.reddit.Comment in project Reader by TheKeeperOfPie.
the class ControllerInbox method insertComment.
public void insertComment(Comment comment) {
// Placeholder to use ArrayList.indexOfLink() properly
Comment parentComment = new Comment();
parentComment.setId(comment.getParentId());
int commentIndex = data.getChildren().indexOf(parentComment);
if (commentIndex > -1) {
// Level and context are set as they are not provided by the send API
parentComment = (Comment) data.getChildren().get(commentIndex);
comment.setLevel(parentComment.getLevel() + 1);
comment.setContext(parentComment.getContext());
data.getChildren().add(commentIndex + 1, comment);
for (Listener listener : listeners) {
listener.getAdapter().notifyItemInserted(commentIndex + 1);
}
}
}
use of com.winsonchiu.reader.data.reddit.Comment in project Reader by TheKeeperOfPie.
the class FragmentReply method newInstance.
public static FragmentReply newInstance(Replyable replyable) {
FragmentReply fragment = new FragmentReply();
Bundle args = new Bundle();
args.putString(ARG_NAME_PARENT, replyable.getName());
args.putCharSequence(ARG_TEXT, replyable.getReplyText());
args.putCharSequence(ARG_TEXT_PARENT, replyable.getParentHtml());
if (replyable instanceof Comment) {
args.putBoolean(ARG_IS_EDIT, ((Comment) replyable).isEditMode());
args.putInt(ARG_COMMENT_LEVEL, ((Comment) replyable).getLevel());
}
fragment.setArguments(args);
return fragment;
}
Aggregations