Fix / Room list empty state flickering
This commit is contained in:
parent
b45585f7c0
commit
d42761f98a
|
@ -251,7 +251,10 @@ class RoomListFragment @Inject constructor(
|
|||
.also { controller ->
|
||||
section.livePages.observe(viewLifecycleOwner) { pl ->
|
||||
controller.submitList(pl)
|
||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(isHidden = pl.isEmpty()))
|
||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||
isHidden = pl.isEmpty(),
|
||||
isLoading = false
|
||||
))
|
||||
checkEmptyState()
|
||||
}
|
||||
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
||||
|
@ -271,7 +274,10 @@ class RoomListFragment @Inject constructor(
|
|||
.also { controller ->
|
||||
section.liveSuggested.observe(viewLifecycleOwner) { info ->
|
||||
controller.setData(info)
|
||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(isHidden = info.rooms.isEmpty()))
|
||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||
isHidden = info.rooms.isEmpty(),
|
||||
isLoading = false
|
||||
))
|
||||
checkEmptyState()
|
||||
}
|
||||
section.isExpanded.observe(viewLifecycleOwner) { _ ->
|
||||
|
@ -285,7 +291,9 @@ class RoomListFragment @Inject constructor(
|
|||
.also { controller ->
|
||||
section.liveList?.observe(viewLifecycleOwner) { list ->
|
||||
controller.setData(list)
|
||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(isHidden = list.isEmpty()))
|
||||
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
|
||||
isHidden = list.isEmpty(),
|
||||
isLoading = false))
|
||||
checkEmptyState()
|
||||
}
|
||||
section.notificationCount.observe(viewLifecycleOwner) { counts ->
|
||||
|
@ -393,8 +401,9 @@ class RoomListFragment @Inject constructor(
|
|||
}
|
||||
|
||||
private fun checkEmptyState() {
|
||||
val hasNoRoom = adapterInfosList.all { it.headerHeaderAdapter.roomsSectionData.isHidden }
|
||||
if (hasNoRoom) {
|
||||
val shouldShowEmpty = adapterInfosList.all { it.headerHeaderAdapter.roomsSectionData.isHidden }
|
||||
&& !adapterInfosList.any { it.headerHeaderAdapter.roomsSectionData.isLoading }
|
||||
if (shouldShowEmpty) {
|
||||
val emptyState = when (roomListParams.displayMode) {
|
||||
RoomListDisplayMode.NOTIFICATIONS -> {
|
||||
StateView.State.Empty(
|
||||
|
@ -422,7 +431,12 @@ class RoomListFragment @Inject constructor(
|
|||
}
|
||||
views.stateView.state = emptyState
|
||||
} else {
|
||||
// is there something to show already?
|
||||
if (adapterInfosList.any { !it.headerHeaderAdapter.roomsSectionData.isHidden }) {
|
||||
views.stateView.state = StateView.State.Content
|
||||
} else {
|
||||
views.stateView.state = StateView.State.Loading
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,9 @@ class SectionHeaderAdapter constructor(
|
|||
val isExpanded: Boolean = true,
|
||||
val notificationCount: Int = 0,
|
||||
val isHighlighted: Boolean = false,
|
||||
val isHidden: Boolean = true
|
||||
val isHidden: Boolean = true,
|
||||
// This will be false until real data has been submitted once
|
||||
val isLoading: Boolean = true
|
||||
)
|
||||
|
||||
lateinit var roomsSectionData: RoomsSectionData
|
||||
|
|
Loading…
Reference in New Issue