Avoid loading pager before pages known

Change-Id: I427e3e5ef9a27004b7b5f5e4eb6a2f45f8141c50
This commit is contained in:
SpiritCroc 2022-03-31 11:01:00 +02:00
parent 36c290f112
commit 45613792bf
2 changed files with 16 additions and 3 deletions

View File

@ -36,6 +36,7 @@ import im.vector.app.R
import im.vector.app.RoomGroupingMethod
import im.vector.app.core.extensions.restart
import im.vector.app.core.extensions.toMvRxBundle
import im.vector.app.core.platform.StateView
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.resources.ColorProvider
@ -521,6 +522,13 @@ class HomeDetailFragment @Inject constructor(
private fun setupViewPager(roomGroupingMethod: RoomGroupingMethod, spaces: List<RoomSummary>?, tab: HomeTab) {
val oldAdapter = views.roomListContainerPager.adapter as? FragmentStateAdapter
val pagingAllowed = vectorPreferences.enableSpacePager() && tab is HomeTab.RoomList
if (pagingAllowed && spaces == null) {
Timber.i("Home pager: Skip initial setup, root spaces not known yet")
views.roomListContainerStateView.state = StateView.State.Loading
return
} else {
views.roomListContainerStateView.state = StateView.State.Content
}
if (DEBUG_VIEW_PAGER) Timber.i("Home pager: setup, old adapter: $oldAdapter")
val unsafeSpaces = spaces?.map { it.roomId } ?: listOf()
val selectedSpaceId = (roomGroupingMethod as? RoomGroupingMethod.BySpace)?.spaceSummary?.roomId

View File

@ -146,12 +146,17 @@
app:layout_constraintTop_toBottomOf="@id/homeKeysBackupBanner" />
-->
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/roomListContainerPager"
<im.vector.app.core.platform.StateView
android:id="@+id/roomListContainerStateView"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
app:layout_constraintTop_toBottomOf="@+id/homeKeysBackupBanner" />
app:layout_constraintTop_toBottomOf="@+id/homeKeysBackupBanner">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/roomListContainerPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</im.vector.app.core.platform.StateView>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigationView"