Status Update
Comments
xt...@gmail.com <xt...@gmail.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.
xt...@gmail.com <xt...@gmail.com> #3
Turns out, we already had a tracking bug for this issue, will follow up on that other one.
xt...@gmail.com <xt...@gmail.com> #4
Thank you for promptly replying to my report. You are right that the issue you've just mentioned is similar to mine. I shall continue observing the progress over there.
il...@google.com <il...@google.com> #5
Please include a sample project that reproduces your issue.
xt...@gmail.com <xt...@gmail.com> #6
There is no need to attach sample project.
Simply use those activity & fragment version when you animating (both animation has the same duration) show() & hide() fragment within single transaction.
Simply use those activity & fragment version when you animating (both animation has the same duration) show() & hide() fragment within single transaction.
il...@google.com <il...@google.com> #7
Given we have tests for show() and hide() that do not reproduce this, it would be helpful if you could provide a project that does reproduce it.
Description
if (shouldAnimateFragmentChange) setCustomAnimations(
R.anim.slide_in,
R.anim.slide_out,
R.anim.back_slide_in,
R.anim.back_slide_out
) else setCustomAnimations(0, 0, 0, 0)
currentFragment?.also { fragment ->
if (isFragmentFound) {
show(fragment)
} else {
add(R.id.fcv_main, fragment, fragment::
}
supportFragmentManager.fragments.forEach {
if (it is BFragment && it !is DialogFragment && it != fragment) hide(it)
}
}
setPrimaryNavigationFragment(currentFragment)
commitAllowingStateLoss()
}
Versions: fragment, fragmentKtx -> 1.3.0-rc01
activity, activityKtx -> 1.2.0-rc01
Gist -> xml animation (