There's a known issue that if you use the hiding strategy on the fragment switch, the fragment's lifecycle won't be changed.
However, there's a new setMaxLifecycle function been added in the FragmentTransaction which can set the maximum lifecycle state during the transaction, and ViewPager2.FragmentStateAdapter actually has such implementation.
Bringing this function call to the library for the hiding strategy, so the fragment lifecycle will be triggered properly during switching.
What have been changed in this PR:
Offered a setMaxLifecycleOnSwitch flag in FragNavController, and set max lifecycle to "Started" for those fragments that are going to be hidden in the transaction.
Updated quite a lot of dependencies and gradle plugins
Story
There's a known issue that if you use the hiding strategy on the fragment switch, the fragment's lifecycle won't be changed.
However, there's a new setMaxLifecycle function been added in the
FragmentTransaction
which can set the maximum lifecycle state during the transaction, andViewPager2.FragmentStateAdapter
actually has such implementation.Bringing this function call to the library for the hiding strategy, so the fragment lifecycle will be triggered properly during switching.
What have been changed in this PR:
setMaxLifecycleOnSwitch
flag inFragNavController
, and set max lifecycle to "Started" for those fragments that are going to be hidden in the transaction.Related issue: https://github.com/ncapdevi/FragNav/issues/244
Original pull request: https://github.com/bandlab/FragNav/pull/2 coauthored by @gildor