Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save 2hamed/0c9edef22511d77511ea2742e7c9f2fe to your computer and use it in GitHub Desktop.

Select an option

Save 2hamed/0c9edef22511d77511ea2742e7c9f2fe to your computer and use it in GitHub Desktop.
navEvents.subscribe {
when (it.destination) {
NavEvent.Destination.ONE -> navController.popBackStack(R.id.fragmentOne, false)
NavEvent.Destination.TWO -> navController.navigate(R.id.action_fragmentOne_to_fragmentTwo)
NavEvent.Destination.THREE -> when (navController.currentDestination!!.id) {
R.id.fragmentOne -> navController.navigate(R.id.action_fragmentOne_to_fragmentThree)
R.id.fragmentTwo -> navController.navigate(R.id.action_fragmentTwo_to_fragmentThree)
}
NavEvent.Destination.FOUR -> navController.navigate(R.id.action_fragmentTwo_to_fragmentFour)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment