Skip to content

Commit

Permalink
fix: Hash fuctions, supressed link detail crash
Browse files Browse the repository at this point in the history
  • Loading branch information
feelfreelinux committed Oct 28, 2018
1 parent 081fc5c commit bbb2c94
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Entry(
}

override fun hashCode(): Int {
return id + author.group + body.length
return (id + author.group + body.length).hashCode()
}

val url: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class Link(
return 0
}

override fun hashCode(): Int {
return this.id.hashCode()
}

val date: String
get() = this.fullDate.toPrettyDate()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,26 @@ class LinkDetailsAdapter @Inject constructor(
}

override fun onBindViewHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
if (holder.itemViewType == LinkHeaderViewHolder.TYPE_HEADER) {
link?.let { (holder as LinkHeaderViewHolder).bindView(link!!) }
} else if (holder is BlockedViewHolder) {
holder.bindView(commentsList!![position - 1])
} else {
val comment = commentsList!![position - 1]
if (holder is TopLinkCommentViewHolder) {
holder.bindView(comment, link!!.author?.nick == comment.author.nick, highlightCommentId)
holder.containerView.tag =
if (comment.childCommentCount > 0 && !comment.isCollapsed) RecyclableViewHolder.SEPARATOR_SMALL else RecyclableViewHolder.SEPARATOR_NORMAL
} else if (holder is LinkCommentViewHolder) {
val parent = commentsList!!.first { it.id == comment.parentId }
val index = commentsList!!.subList(commentsList!!.indexOf(parent), position - 1).size
holder.bindView(comment, link!!.author?.nick == comment.author.nick, highlightCommentId)
holder.itemView.tag =
if (parent.childCommentCount == index) RecyclableViewHolder.SEPARATOR_NORMAL else RecyclableViewHolder.SEPARATOR_SMALL
try { // Suppresing, need more information to reproduce this crash.
if (holder.itemViewType == LinkHeaderViewHolder.TYPE_HEADER) {
link?.let { (holder as LinkHeaderViewHolder).bindView(link!!) }
} else if (holder is BlockedViewHolder) {
holder.bindView(commentsList!![position - 1])
} else {
val comment = commentsList!![position - 1]
if (holder is TopLinkCommentViewHolder) {
holder.bindView(comment, link!!.author?.nick == comment.author.nick, highlightCommentId)
holder.containerView.tag =
if (comment.childCommentCount > 0 && !comment.isCollapsed) RecyclableViewHolder.SEPARATOR_SMALL else RecyclableViewHolder.SEPARATOR_NORMAL
} else if (holder is LinkCommentViewHolder) {
val parent = commentsList!!.first { it.id == comment.parentId }
val index = commentsList!!.subList(commentsList!!.indexOf(parent), position - 1).size
holder.bindView(comment, link!!.author?.nick == comment.author.nick, highlightCommentId)
holder.itemView.tag =
if (parent.childCommentCount == index) RecyclableViewHolder.SEPARATOR_NORMAL else RecyclableViewHolder.SEPARATOR_SMALL
}
}
} catch (e: Exception) {
}
}

Expand Down

0 comments on commit bbb2c94

Please sign in to comment.