mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 03:49:04 +03:00
Fix / Room list empty state flickering
This commit is contained in:
parent
b45585f7c0
commit
d42761f98a
2 changed files with 23 additions and 7 deletions
|
@ -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 {
|
||||
views.stateView.state = StateView.State.Content
|
||||
// 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 a new issue