mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
Cleanup
This commit is contained in:
parent
8b39c4e56a
commit
a295dfb248
@ -28,14 +28,12 @@ class BlockedContactsAdapter(val viewModel: BlockedContactsViewModel) : ListAdap
|
||||
.let(::ViewHolder)
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val selectable = getItem(position)
|
||||
holder.bind(selectable, viewModel::toggle)
|
||||
holder.bind(getItem(position), viewModel::toggle)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int, payloads: MutableList<Any>) {
|
||||
val selectable = getItem(position)
|
||||
if (payloads.isEmpty()) holder.bind(selectable, viewModel::toggle)
|
||||
else holder.select(selectable.isSelected)
|
||||
if (payloads.isEmpty()) holder.bind(getItem(position), viewModel::toggle)
|
||||
else holder.select(getItem(position).isSelected)
|
||||
}
|
||||
|
||||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
|
@ -31,7 +31,7 @@ class BlockedContactsViewModel @Inject constructor(private val storage: Storage)
|
||||
|
||||
private val listUpdateChannel = Channel<Unit>(capacity = Channel.CONFLATED)
|
||||
|
||||
private val _state = MutableLiveData(BlockedContactsViewState(emptyList(), emptySet()))
|
||||
private val _state = MutableLiveData(BlockedContactsViewState())
|
||||
|
||||
val state get() = _state.value!!
|
||||
|
||||
@ -110,12 +110,11 @@ class BlockedContactsViewModel @Inject constructor(private val storage: Storage)
|
||||
}
|
||||
|
||||
data class BlockedContactsViewState(
|
||||
val blockedContacts: List<Recipient>,
|
||||
val selectedItems: Set<Recipient>
|
||||
val blockedContacts: List<Recipient> = emptyList(),
|
||||
val selectedItems: Set<Recipient> = emptySet()
|
||||
) {
|
||||
val items = blockedContacts.map { SelectableItem(it, it in selectedItems) }
|
||||
|
||||
val isEmpty get() = blockedContacts.isEmpty()
|
||||
val unblockButtonEnabled get() = selectedItems.isNotEmpty()
|
||||
val emptyStateMessageTextViewVisible get() = blockedContacts.isEmpty()
|
||||
val nonEmptyStateGroupVisible get() = blockedContacts.isNotEmpty()
|
||||
|
Loading…
x
Reference in New Issue
Block a user