Skip to content

Instantly share code, notes, and snippets.

@huan-nguyen
Created July 6, 2020 04:57
Show Gist options
  • Select an option

  • Save huan-nguyen/779b67d46fa7059f500d1a8aeabc7e77 to your computer and use it in GitHub Desktop.

Select an option

Save huan-nguyen/779b67d46fa7059f500d1a8aeabc7e77 to your computer and use it in GitHub Desktop.

Revisions

  1. huan-nguyen created this gist Jul 6, 2020.
    11 changes: 11 additions & 0 deletions NavControllerNavigate.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    /**
    This is only pseudo code to illustrate the process of locating Navigator
    to handle the navigation to a particular destination.
    It is not the real code in Navigation Component.
    */
    fun NavController.navigate(@IdRes destinationResId: Int) {
    val destination = navGraph.getDestination(destinationResId)
    val navigator = navigatorProvider.getNavigator(destination.navigatorName)
    navigator.navigate(destination)
    }