RoomList: fix count not showing if not collapsable

This commit is contained in:
ganfra 2022-03-24 18:49:57 +01:00
parent 81aa42a8e8
commit 87438085c6

View file

@ -16,8 +16,8 @@
package im.vector.app.features.home.room.list
import android.graphics.drawable.Drawable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
@ -86,16 +86,16 @@ class SectionHeaderAdapter constructor(
fun bind(roomsSectionData: RoomsSectionData) {
binding.roomCategoryTitleView.text = roomsSectionData.name
val tintColor = ThemeUtils.getColor(binding.root.context, R.attr.vctr_content_secondary)
if (roomsSectionData.isCollapsable) {
binding.roomCategoryCounterView.visibility = View.VISIBLE
val collapsableArrowDrawable: Drawable? = if (roomsSectionData.isCollapsable) {
val expandedArrowDrawableRes = if (roomsSectionData.isExpanded) R.drawable.ic_expand_more else R.drawable.ic_expand_less
val expandedArrowDrawable = ContextCompat.getDrawable(binding.root.context, expandedArrowDrawableRes)?.also {
ContextCompat.getDrawable(binding.root.context, expandedArrowDrawableRes)?.also {
DrawableCompat.setTint(it, tintColor)
}
binding.roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null)
} else {
binding.roomCategoryCounterView.visibility = View.GONE
null
}
binding.root.isClickable = roomsSectionData.isCollapsable
binding.roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, collapsableArrowDrawable, null)
binding.roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty()
binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted))
}