-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix resetting the TurboSessionNavHostFragment
#251
Conversation
…f the navigation library do not recreate/clear the backstack if the new nav graph is identical to the existing one
The original approach is too naive and will not work 😩. Got this crash when the app tried to restore the backstack when resuming from the background. The destination routes need to be identical across app restores so the original destination in the backstack can be found.
|
…nique_instance` argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite an inventive approach using the argument value to differentiate the graphs 👍
Nice, thanks!
Newer versions of the navigation library do not recreate/clear the backstack when updating the nav graph in
NavController.setGraph()
if it's identical to the existing one. This brings back the previous behavior ofTurboSessionNavHostFragment.reset()
by using a randomInt
as a graphunique_instance
argument.This also switches to
String
-based routes instead of using anID
, since the navigation library has deprecated theID
-based approach.