chinwag-android/app
Nik Clayton 196ebdb386
Keep the tabs adapter over the life of the viewpager (#3255)
Make `tabs` `var` instead of `val` in `MainPagerAdapter` so it can be updated
when tabs change.

Then detach the `tabLayoutMediator`, update the tabs, and call
`notifyItemRangeChanged` in `setupTabs()`.

This fixes a bug (not sure if it's this code, or in ViewPager2) where
assigning a new adapter to the view pager seemed to result in a leak of one
or more fragments. This wasn't user-visible, but it's a leak, and it becomes
user-visible when fragments want to display menus.

This also fixes two other bugs:

1. Be on the left-most tab. Scroll down a bit. Then modify the tabs at
   "Account preferences > tabs", but keep the left-most tab as-is.

   Then go back to MainActivity. Your reading position in the left-most
   tab has been jumped to the top.

2. Be on any non-left-most tab. Then modify the tab list by reordering tabs
   (adding/removing tabs is also OK).

   Then go back to MainActivity. Your tab selection has been overridden,
   and the left-most tab has been selected.

Because the fragments are not destroyed unnecessarily your reading position
is retained. And it remembers the tab you had selected, and as long as that
tab is still present you will be returned to it, even if it's changed
position in the list.

Fixes https://github.com/tuskyapp/Tusky/issues/3251
2023-02-15 19:17:59 +01:00
..
schemas/com.keylesspalace.tusky.db.AppDatabase Dialog notifying user of failure when media upload fails (#3135) 2023-01-27 20:50:45 +01:00
src Keep the tabs adapter over the life of the viewpager (#3255) 2023-02-15 19:17:59 +01:00
build.gradle Fix sporadic failure in non-git build (using patch by @nikclayton) (#3307) 2023-02-14 20:15:42 +01:00
proguard-rules.pro Keep all subclasses of PreferenceFragmentCompat (#3162) 2023-01-13 19:51:42 +01:00