Skip to content

Instantly share code, notes, and snippets.

@vegeta2102
Created March 12, 2021 23:28
Show Gist options
  • Save vegeta2102/769c463858ca09bcecf395656a8a1498 to your computer and use it in GitHub Desktop.
Save vegeta2102/769c463858ca09bcecf395656a8a1498 to your computer and use it in GitHub Desktop.
@AndroidEntryPoint
class NextScreenFragment : Fragment(R.layout.fragment_next_screen) {
private val navigation: NavController by lazy {
findNavController()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
observeViewModel()
}
private fun observeViewModel() {
with(nextScreenViewModel) {
backRequest.observe(viewLifecycleOwner) {
navigation.previousBackStackEntry?.savedStateHandle?.set("key",true)
navigation.popBackStack()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment