Skip to content

Commit

Permalink
Be more defensive in date parsing on DN story comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher committed Nov 19, 2015
1 parent 4b40105 commit f0e7d00
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions app/src/main/java/io/plaidapp/ui/DesignerNewsStory.java
Original file line number Diff line number Diff line change
Expand Up @@ -721,29 +721,30 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (getItemViewType(position) == TYPE_COMMENT) {
bindComment((CommentHolder) holder, comments.get(position - 1)); // minus header
bindComment((CommentHolder) holder, comments.get(position - 1).comment);
} // nothing to bind for header / no comment / footer views
}

private void bindComment(final CommentHolder holder, final ThreadedComment comment) {
HtmlUtils.setTextWithNiceLinks(holder.comment, markdown.markdownToSpannable(comment
.comment.body, holder.comment, new Bypass.LoadImageCallback() {
@Override
public void loadImage(String src, ImageLoadingSpan loadingSpan) {
Glide.with(DesignerNewsStory.this)
.load(src)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(new ImageSpanTarget(holder.comment, loadingSpan));
}
}));
holder.author.setText(comment.comment.user_display_name);
holder.author.setOriginalPoster(isOP(comment
.comment.user_id));
holder.timeAgo.setText(
DateUtils.getRelativeTimeSpanString(comment.comment.created_at.getTime(),
System.currentTimeMillis(),
DateUtils.SECOND_IN_MILLIS));
private void bindComment(final CommentHolder holder, final Comment comment) {
HtmlUtils.setTextWithNiceLinks(holder.comment, markdown.markdownToSpannable(
comment.body, holder.comment, new Bypass.LoadImageCallback() {
@Override
public void loadImage(String src, ImageLoadingSpan loadingSpan) {
Glide.with(DesignerNewsStory.this)
.load(src)
.asBitmap()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(new ImageSpanTarget(holder.comment, loadingSpan));
}
}));
holder.author.setText(comment.user_display_name);
holder.author.setOriginalPoster(isOP(comment.user_id));
if (comment.created_at != null) {
holder.timeAgo.setText(
DateUtils.getRelativeTimeSpanString(comment.created_at.getTime(),
System.currentTimeMillis(),
DateUtils.SECOND_IN_MILLIS));
}
ThreadedCommentDrawable depthDrawable = new ThreadedCommentDrawable(threadWidth,
threadGap);
depthDrawable.setDepth(comment.depth);
Expand Down

0 comments on commit f0e7d00

Please sign in to comment.