Fixed
Status Update
Comments
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
Fixed internally and will be available in navigation 2.8.0-alpha02
.
il...@google.com <il...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit db700c8e99e354fbc35cf4bbd5f6f811deb587a0
Author: Clara Fok <clarafok@google.com>
Date: Wed Jan 31 16:19:02 2024
Fix NavGraph ViewModel destroyed too soon
The NavGraph entry when popped gets stored into savedState bundle but the entry's ViewModel is cleared from the ViewModelStore because we did not track the entry's saveState. We used to only track the saveState on FragmentNavigator and ComposeNavigator. Now whenever we pop, the base NavControllerNavigatorState would add the entry to map of saveState so we don't destroy the VM prematurely.
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 317581849
Change-Id: Ib6bb7d1d2f1af928a23a2647b1800eb4bb37d39d
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
https://android-review.googlesource.com/2942087
Branch: androidx-main
commit db700c8e99e354fbc35cf4bbd5f6f811deb587a0
Author: Clara Fok <clarafok@google.com>
Date: Wed Jan 31 16:19:02 2024
Fix NavGraph ViewModel destroyed too soon
The NavGraph entry when popped gets stored into savedState bundle but the entry's ViewModel is cleared from the ViewModelStore because we did not track the entry's saveState. We used to only track the saveState on FragmentNavigator and ComposeNavigator. Now whenever we pop, the base NavControllerNavigatorState would add the entry to map of saveState so we don't destroy the VM prematurely.
Test: ./gradlew navigation:navigation-runtime:cC
Bug: 317581849
Change-Id: Ib6bb7d1d2f1af928a23a2647b1800eb4bb37d39d
M navigation/navigation-runtime/src/androidTest/java/androidx/navigation/NavControllerTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
Description
Version used: 1.0.0-rc01
I recently worked on an app with package name 'in.bitotsav', and used navigation architecture component to implement a single activity structure. I had been using safeargs using
apply plugin: "androidx.navigation.safeargs"
But just now, I discovered the availability of "androidx.navigation.safeargs.kotlin", so I tried applying it. But it leads to compilation error due to the 'in' part of the package name not being escaped in the generated code, for statements like:
override fun getActionId(): Int = in.bitotsav.R.id.action_global_destEventDetail
and
fun actionDestLoginToDestRegistration(): NavDirections =
ActionOnlyNavDirections(in.bitotsav.R.id.action_destLogin_to_destRegistration)
This can be fixed if the 'in' is escaped with backticks, as:
override fun getActionId(): Int = `in`.bitotsav.R.id.action_global_destEventDetail
This is also what is done by android studio in imports.
Version Info:
minSdkVersion 21
targetSdkVersion 28
Android Studio 3.5 Canary 3
Build #AI-183.5153.38.35.5256920, built on January 24, 2019
JRE: 1.8.0_152-release-1248-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.20.8-arch1-1-ARCH