use of com.winsonchiu.reader.data.reddit.Thing in project Reader by TheKeeperOfPie.
the class ControllerComments method setLinkWithComments.
public void setLinkWithComments(Link link) {
link.setBackgroundColor(this.link.getBackgroundColor());
this.link = link;
Listing listing = new Listing();
// For some reason Reddit doesn't report the link author, so we'll do it manually
for (Thing thing : link.getComments().getChildren()) {
Comment comment = (Comment) thing;
comment.setLinkAuthor(link.getAuthor());
}
// TODO: Make this logic cleaner
if (link.getComments() != null) {
listing.setChildren(new ArrayList<>(link.getComments().getChildren()));
} else {
listing.setChildren(new ArrayList<>());
}
listingComments = listing;
if (sharedPreferences.getBoolean(AppSettings.PREF_COLLAPSE_COMMENT_THREADS, false)) {
for (int index = listingComments.getChildren().size() - 1; index >= 0; index--) {
if (((Comment) listingComments.getChildren().get(index)).getLevel() == 0) {
collapseComment(index, false);
}
}
}
eventHolder.call(new RxAdapterEvent<>(getData()));
}
Aggregations