Skip to content

Instantly share code, notes, and snippets.

@aartikov
Last active September 25, 2020 15:25
Show Gist options
  • Save aartikov/c70214115ab93f78d73b1e1ce97779bf to your computer and use it in GitHub Desktop.
Save aartikov/c70214115ab93f78d73b1e1ce97779bf to your computer and use it in GitHub Desktop.
navigation
private fun bindNavigationContext() {
val builder = NavigationContext.Builder(this, navigationFactory)
val currentFlowFragment = getCurrentFlowFragment()
if (currentFlowFragment is ContainerIdProvider) {
builder.fragmentNavigation(
currentFlowFragment.childFragmentManager,
(currentFlowFragment as ContainerIdProvider).containerId
)
}
if (currentFlowFragment is ScreenSwitcherProvider) {
builder.screenSwitcher(
(currentFlowFragment as ScreenSwitcherProvider).screenSwitcher
)
}
builder.flowFragmentNavigation(supportFragmentManager, R.id.screenContainer)
.transitionListener { _, destinationType: DestinationType, _, _ ->
if (destinationType == DestinationType.FLOW_FRAGMENT) {
bindNavigationContext()
}
}
.screenSwitchingListener {
bindNavigationContext()
}
navigationContextBinder.bind(builder.build())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment