Revert "Do not suggest collapse if there is only one section"
This reverts commit 6787980185
.
This commit is contained in:
parent
4755ebfa97
commit
55b1a60f96
|
@ -295,8 +295,7 @@ class RoomListFragment @Inject constructor(
|
||||||
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
||||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||||
notificationCount = counts.totalCount,
|
notificationCount = counts.totalCount,
|
||||||
isHighlighted = counts.isHighlight,
|
isHighlighted = counts.isHighlight
|
||||||
shouldShowExpandedArrow = shouldShowExpendedArrow()
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
||||||
|
@ -330,17 +329,14 @@ class RoomListFragment @Inject constructor(
|
||||||
controller.setData(list)
|
controller.setData(list)
|
||||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||||
isHidden = list.isEmpty(),
|
isHidden = list.isEmpty(),
|
||||||
isLoading = false,
|
isLoading = false))
|
||||||
shouldShowExpandedArrow = shouldShowExpendedArrow()
|
|
||||||
))
|
|
||||||
checkEmptyState()
|
checkEmptyState()
|
||||||
}
|
}
|
||||||
observeItemCount(section, sectionAdapter)
|
observeItemCount(section, sectionAdapter)
|
||||||
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
||||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||||
notificationCount = counts.totalCount,
|
notificationCount = counts.totalCount,
|
||||||
isHighlighted = counts.isHighlight,
|
isHighlighted = counts.isHighlight
|
||||||
shouldShowExpandedArrow = shouldShowExpendedArrow()
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
||||||
|
@ -448,10 +444,6 @@ class RoomListFragment @Inject constructor(
|
||||||
footerController.setData(state)
|
footerController.setData(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun shouldShowExpendedArrow(): Boolean {
|
|
||||||
return adapterInfosList.filter { !it.sectionHeaderAdapter.roomsSectionData.isHidden }.size >= 2
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun checkEmptyState() {
|
private fun checkEmptyState() {
|
||||||
val shouldShowEmpty = adapterInfosList.all { it.sectionHeaderAdapter.roomsSectionData.isHidden } &&
|
val shouldShowEmpty = adapterInfosList.all { it.sectionHeaderAdapter.roomsSectionData.isHidden } &&
|
||||||
!adapterInfosList.any { it.sectionHeaderAdapter.roomsSectionData.isLoading }
|
!adapterInfosList.any { it.sectionHeaderAdapter.roomsSectionData.isLoading }
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package im.vector.app.features.home.room.list
|
package im.vector.app.features.home.room.list
|
||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.graphics.drawable.DrawableCompat
|
import androidx.core.graphics.drawable.DrawableCompat
|
||||||
|
@ -40,8 +39,7 @@ class SectionHeaderAdapter constructor(
|
||||||
val isHighlighted: Boolean = false,
|
val isHighlighted: Boolean = false,
|
||||||
val isHidden: Boolean = true,
|
val isHidden: Boolean = true,
|
||||||
// This will be false until real data has been submitted once
|
// This will be false until real data has been submitted once
|
||||||
val isLoading: Boolean = true,
|
val isLoading: Boolean = true
|
||||||
val shouldShowExpandedArrow: Boolean = false
|
|
||||||
)
|
)
|
||||||
|
|
||||||
lateinit var roomsSectionData: RoomsSectionData
|
lateinit var roomsSectionData: RoomsSectionData
|
||||||
|
@ -84,16 +82,11 @@ class SectionHeaderAdapter constructor(
|
||||||
fun bind(roomsSectionData: RoomsSectionData) {
|
fun bind(roomsSectionData: RoomsSectionData) {
|
||||||
binding.roomCategoryTitleView.text = roomsSectionData.name
|
binding.roomCategoryTitleView.text = roomsSectionData.name
|
||||||
val tintColor = ThemeUtils.getColor(binding.root.context, R.attr.vctr_content_secondary)
|
val tintColor = ThemeUtils.getColor(binding.root.context, R.attr.vctr_content_secondary)
|
||||||
if (roomsSectionData.shouldShowExpandedArrow) {
|
|
||||||
binding.roomCategoryCounterView.visibility = View.VISIBLE
|
|
||||||
val expandedArrowDrawableRes = if (roomsSectionData.isExpanded) R.drawable.ic_expand_more else R.drawable.ic_expand_less
|
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 {
|
val expandedArrowDrawable = ContextCompat.getDrawable(binding.root.context, expandedArrowDrawableRes)?.also {
|
||||||
DrawableCompat.setTint(it, tintColor)
|
DrawableCompat.setTint(it, tintColor)
|
||||||
}
|
}
|
||||||
binding.roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null)
|
binding.roomCategoryCounterView.setCompoundDrawablesWithIntrinsicBounds(null, null, expandedArrowDrawable, null)
|
||||||
} else {
|
|
||||||
binding.roomCategoryCounterView.visibility = View.GONE
|
|
||||||
}
|
|
||||||
binding.roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty()
|
binding.roomCategoryCounterView.text = roomsSectionData.itemCount.takeIf { it > 0 }?.toString().orEmpty()
|
||||||
binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted))
|
binding.roomCategoryUnreadCounterBadgeView.render(UnreadCounterBadgeView.State(roomsSectionData.notificationCount, roomsSectionData.isHighlighted))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue