Skip to content

Commit

Permalink
Fix conversation swipe actions
Browse files Browse the repository at this point in the history
  • Loading branch information
moezbhatti committed Jan 14, 2020
1 parent 6ea4eb9 commit f8e3e72
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class ConversationsAdapter @Inject constructor(
private val phoneNumberUtils: PhoneNumberUtils
) : QkRealmAdapter<Conversation>() {

init {
// This is how we access the threadId for the swipe actions
setHasStableIds(true)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
val view = layoutInflater.inflate(R.layout.conversation_list_item, parent, false)
Expand Down Expand Up @@ -109,6 +114,10 @@ class ConversationsAdapter @Inject constructor(
holder.unread.setTint(colors.theme(recipient).theme)
}

override fun getItemId(position: Int): Long {
return getItem(position)?.id ?: -1
}

override fun getItemViewType(position: Int): Int {
return if (getItem(position)?.unread == false) 0 else 1
}
Expand Down

0 comments on commit f8e3e72

Please sign in to comment.