Fixed
Status Update
Comments
jb...@google.com <jb...@google.com> #2
You don't need to do step 1 or 2 - ensuring you've called addNavigator() before setGraph() is enough.
Specifically, seehttps://issuetracker.google.com/issues/110763345#comment2
Also mentioned is the fact that you can override createFragmentNavigator(), call navController.navigatorProvider.addNavigator() there, then return super.createFragmentNavigator().
Specifically, see
Also mentioned is the fact that you can override createFragmentNavigator(), call navController.navigatorProvider.addNavigator() there, then return super.createFragmentNavigator().
il...@google.com <il...@google.com> #3
It's may also be of interest that I am making use of a custom navigator to implement conditional routing. My custom destination/nodes simply implement an interface like this:
interface DynamicNode {
@IdRes
fun getDestination(context: Context, @IdRes destinationIn: Int, argsIn: Bundle?) : Int
}
The Navigator then implements a navigate method that simply calls NavController.navigate using the ID returned by the DynamicNode and returns null, essentially performing a redirect. It would be cool to see something like this baked-in with a later version of the Navigation component.
interface DynamicNode {
@IdRes
fun getDestination(context: Context, @IdRes destinationIn: Int, argsIn: Bundle?) : Int
}
The Navigator then implements a navigate method that simply calls NavController.navigate using the ID returned by the DynamicNode and returns null, essentially performing a redirect. It would be cool to see something like this baked-in with a later version of the Navigation component.
zo...@gmail.com <zo...@gmail.com> #4
>> You don't need to do step 1 or 2 - ensuring you've called addNavigator() before setGraph() is enough.
Ah gotcha. Okay that's a nicer then. Thanks!
Ah gotcha. Okay that's a nicer then. Thanks!
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 238c09170a34e1c94af42bc3c6e9fce551883aef
Author: Ian Lake <ilake@google.com>
Date: Mon Apr 22 12:54:51 2019
Rename createFragmentNavigator()
Fix confusion around what method should
be overriden to add custom Navigators to
a NavHostFragment.
Test: tested in testapp
Fixes: 122802849
Change-Id: I969dca429a62e0533cb4ca93c77e68e062278a6f
M navigation/fragment/api/2.1.0-alpha03.txt
M navigation/fragment/api/current.txt
M navigation/fragment/src/main/java/androidx/navigation/fragment/NavHostFragment.java
https://android-review.googlesource.com/947645
https://goto.google.com/android-sha1/238c09170a34e1c94af42bc3c6e9fce551883aef
Branch: androidx-master-dev
commit 238c09170a34e1c94af42bc3c6e9fce551883aef
Author: Ian Lake <ilake@google.com>
Date: Mon Apr 22 12:54:51 2019
Rename createFragmentNavigator()
Fix confusion around what method should
be overriden to add custom Navigators to
a NavHostFragment.
Test: tested in testapp
Fixes: 122802849
Change-Id: I969dca429a62e0533cb4ca93c77e68e062278a6f
M navigation/fragment/api/2.1.0-alpha03.txt
M navigation/fragment/api/current.txt
M navigation/fragment/src/main/java/androidx/navigation/fragment/NavHostFragment.java
jb...@google.com <jb...@google.com> #6
We've decided to rename createFragmentNavigator() to onCreateNavController(NavController) to make it more clear that this is something you can override to get a callback for when the NavController is created.
This will be available in Navigation 2.1.0-alpha03
This will be available in Navigation 2.1.0-alpha03
Description
Component used: Navigation Version used: androidx.navigation:navigation-*:2.4.0-alpha01 Devices/Android versions reproduced on:
I don't have a repro project, but I do have a stacktrace: