Skip to content

Instantly share code, notes, and snippets.

@ininmm
Created October 11, 2019 12:46
Show Gist options
  • Save ininmm/3b5b44903c187d81a04fcb3988f81170 to your computer and use it in GitHub Desktop.
Save ininmm/3b5b44903c187d81a04fcb3988f81170 to your computer and use it in GitHub Desktop.
Allowing the fragment to use NavigationUI methods without crashing.
val scenario = launchFragmentInContainer {
TitleScreen().also { fragment ->
fragment.viewLifecycleOwnerLiveData.observeForever { viewLifecycleOwner ->
if (viewLifecycleOwner != null) {
Navigation.setViewNavController(
fragment.requireView(),
mockNavController
)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment