diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt index eb931f9e9c..eeacdad363 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt @@ -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 + } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt b/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt index f9c5766821..6cddf72c5a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt @@ -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