Status Update
Comments
jb...@google.com <jb...@google.com> #2
This actually has nothing to do with NavHostFragment, but is the behavior of NavController's setGraph().
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
Description
Component used: Fragment
Version used: 1.3.0-beta01
Devices/Android versions reproduced on: 9.0
My project hasn't fully migrated from using the deprecated
onActivityCreated()
function. After updating to1.3.0-beta01
, I noticed the following:I have
FragmentA
which is aDialogFragment
andFragmentB
which is aFragment
that contains aWebView
.FragmentA
has aFragmentContainerView
whereFragmentB
gets added inonActivityCreated()
.If I call
setCustomAnimations()
in the transaction that's used to addFragmentB
, then theWebView
will not render.I'm attaching a sample project to better demonstrate the issue.
Possible workarounds which solve the issue:
onActivityCreated()
withonViewCreated()
(it's on my todo list to do this for my whole project)setCustomAnimations