Last active
May 11, 2019 19:34
-
-
Save PHELAT/601b2e646261de175ecaaf196e8133a6 to your computer and use it in GitHub Desktop.
navigateUp with Bundle!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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