gateship-one / odyssey

Odyssey music player
GNU General Public License v3.0
232 stars 39 forks source link

Fix remembering scrolling position #238

Closed SpringerJack closed 2 years ago

SpringerJack commented 2 years ago

Relates to #232

Since 005835269af99eae73b0a13cacce386334c20ee0 the tabs albums and artists do not remember the user's position anymore. The culprit seems to be a call not happening early on in onCreateView() but rather with initialization in onViewCreated().

Reverting this does not seem like an ideal solution. Suggestions are welcome in case anybody knows how to handle this properly.

gnome17 commented 2 years ago

Hi many thanks for this :)

I did some digging and it turns out that the call of setOffscreenPageLimit will trigger an unwanted update of the underlying adapter and in our case updates of the fragments in this adapter. In my debug sessions actually three unwanted updates.

It turns out it would be sufficient to just call setOffscreenPageLimit before the adapter of the viewpager is set. I already pushed this fix to our main branch, I hope you don't mind. But again many thanks for your investigation, I most likely wouldn't found the cause for this issue without your help.

SpringerJack commented 2 years ago

I'm just glad I could help and that you found a sane workaround. This PR was never intended to be a merge request anyway, so no worries about pushing the proper fix :+1: