From 9b1717c321132a0aec9fb8423e5ade22f77739d2 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Thu, 27 Mar 2025 19:00:59 +0100 Subject: [PATCH] fix Tusky sometimes displaying empty tabs (#5007) Sometimes a tab is just empty after switching to it, but content appears as soon as you interact with it. I found that setting a `offscreenPageLimit` on the `ViewPager2` makes that issue go away. This also has the side effect that the content of more tabs is preloaded, which makes tab switching *feel* different, one does not see so many loading spinners, content is just there instantly. I'm not sure if that is desireable but I would like to try it out for a while. If it happens to be a problem we can still move tab initialization to when it is actually visible. --- app/src/main/java/com/keylesspalace/tusky/MainActivity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt index 3c01eb2c4..682ad195a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.kt @@ -342,6 +342,7 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider { // https://github.com/tuskyapp/Tusky/issues/3251 for details. tabAdapter = MainPagerAdapter(emptyList(), this@MainActivity) binding.viewPager.adapter = tabAdapter + binding.viewPager.offscreenPageLimit = 2 lifecycleScope.launch { viewModel.tabs.collect(::setupTabs)