mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
optimization on contacts selection
This commit is contained in:
parent
9ccd72bf33
commit
3c210ca437
@ -26,7 +26,7 @@ class SelectContactsAdapter(private val context: Context, private val glide: Gli
|
||||
|
||||
override fun onBindViewHolder(viewHolder: ViewHolder, position: Int) {
|
||||
val member = members[position]
|
||||
viewHolder.view.setOnClickListener { onMemberClick(member) }
|
||||
viewHolder.view.setOnClickListener { onMemberClick(viewHolder, member) }
|
||||
val isSelected = selectedMembers.contains(member)
|
||||
viewHolder.view.bind(Recipient.from(
|
||||
context,
|
||||
@ -36,13 +36,13 @@ class SelectContactsAdapter(private val context: Context, private val glide: Gli
|
||||
isSelected)
|
||||
}
|
||||
|
||||
private fun onMemberClick(member: String) {
|
||||
private fun onMemberClick(viewHolder: ViewHolder, member: String) {
|
||||
if (selectedMembers.contains(member)) {
|
||||
selectedMembers.remove(member)
|
||||
viewHolder.view.toggleCheckbox()
|
||||
} else {
|
||||
selectedMembers.add(member)
|
||||
viewHolder.view.toggleCheckbox(true)
|
||||
}
|
||||
val index = members.indexOf(member)
|
||||
notifyItemChanged(index)
|
||||
}
|
||||
}
|
@ -82,6 +82,11 @@ class UserView : LinearLayout {
|
||||
}
|
||||
}
|
||||
|
||||
fun toggleCheckbox(isSelected: Boolean = false) {
|
||||
actionIndicatorImageView.visibility = View.VISIBLE
|
||||
actionIndicatorImageView.setImageResource(if (isSelected) R.drawable.ic_circle_check else R.drawable.ic_circle)
|
||||
}
|
||||
|
||||
fun unbind() {
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user