Skip to content

Instantly share code, notes, and snippets.

@PHELAT
Last active May 11, 2019 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PHELAT/601b2e646261de175ecaaf196e8133a6 to your computer and use it in GitHub Desktop.
Save PHELAT/601b2e646261de175ecaaf196e8133a6 to your computer and use it in GitHub Desktop.
navigateUp with Bundle!
class FragmentA : BundleFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
myButton.setOnClickListener {
navigate(FragmentADirections.fragmentAToFragmentB(), REQUEST_CODE)
// If you aren't using SafeArgs plugin, you can navigate with direction id
navigate(R.id.fragmentAToFragmentB, REQUEST_CODE)
}
}
override fun onFragmentResult(requestCode: Int, bundle: Bundle) {
if (requestCode == REQUEST_CODE) {
val isLoginSuccessful = bundle.getBoolean(FragmentB.IS_LOG_IN_SUCCESSFUL, false)
...
}
}
companion object {
const val REQUEST_CODE = 1000
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment