Assigned
Status Update
Comments
nj...@google.com <nj...@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.
nj...@google.com <nj...@google.com> #3
Turns out, we already had a tracking bug for this issue, will follow up on that other one.
an...@google.com <an...@google.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.
Description
Simple example would be:
After the flag switched to false, the text drawn by the Text composable will continue to be displayed, but the text drawn by the TextView is not.
The main side effect of it is we don't support disappearance animations via Modifier.animateItem() for the View based content in all the lazy layouts.
This issue was discussed during the design of the list item animations in go/compose-list-item-animations - Issue C, Option 2. Quote from there:
"We will also need some adjustments on how we handle AndroidViews inside items. It is especially important for TextureView or SurfaceView (for example video players). Once we remove a View from the views hierarchy its surface is destroyed. We can solve it by keeping views attached until the animation finishes. We already introduced the AndroidView(onRelease = {}) callback which should be used by the users when the view is fully released. And we already keep views after the AndroidView is disposed when we reuse them during scrolling. In this case we will continue using the same already provided callbacks and will call onRelease only after the animation finishes."
As part of this ticket we need to make this use case work. It will likely require: