Florian
10/15/2020, 8:44 PMFlorian
10/15/2020, 8:44 PMviewModel.user.observe(this) {
if (it == null) {
val action = LoginDirections.actionGlobalLogin()
navController.navigate(action)
}
}
Florian
10/15/2020, 8:45 PMFlorian
10/15/2020, 8:46 PMoverride fun onBackPressed() {
if (navController.currentDestination?.id == R.id.loginFragment) {
finish()
} else {
super.onBackPressed()
}
}
Florian
10/15/2020, 8:46 PMuserViewModel.user.observe(viewLifecycleOwner) {
if (it != null) {
findNavController().popBackStack()
binding.editTextEmail.clearFocus()
binding.editTextPassword.clearFocus()
}
}
Ian Lake
10/15/2020, 8:48 PMFlorian
10/15/2020, 8:48 PMFlorian
10/15/2020, 8:48 PMIan Lake
10/15/2020, 8:50 PMFlorian
10/15/2020, 8:51 PMFlorian
10/15/2020, 8:51 PMIan Lake
10/15/2020, 8:55 PMFlorian
10/15/2020, 8:56 PMFlorian
10/15/2020, 9:11 PMFlorian
10/15/2020, 9:12 PMFlorian
10/15/2020, 9:12 PMIan Lake
10/15/2020, 10:20 PMFlorian
10/15/2020, 10:34 PMFlorian
10/15/2020, 10:35 PMIan Lake
10/16/2020, 12:18 AMFlorian
10/16/2020, 8:17 AMFlorian
10/16/2020, 8:17 AMFlorian
10/16/2020, 8:17 AMobserve
, right?Florian
10/16/2020, 8:26 AMFlorian
10/16/2020, 8:44 AMFlorian
10/16/2020, 9:16 AMIan Lake
10/16/2020, 2:35 PMIan Lake
10/16/2020, 2:36 PMFragmentContainerView
, which has been the recommended approach for quite some time. It sounds like you are still using <fragment>
Florian
10/16/2020, 2:42 PMFlorian
10/16/2020, 2:42 PMFlorian
10/16/2020, 2:49 PMFlorian
10/16/2020, 2:52 PMonViewCreated
it looks like it could make sense to create an extension function for all fragments that need authenticationIan Lake
10/16/2020, 3:14 PMFlorian
10/16/2020, 3:16 PMFlorian
10/16/2020, 9:25 PMLOGIN_SUCCESSFUL
is still false. Is this expected behavior? You don't notice it if you immediately move to another destination without an animation, but you can see it if you for example when you finish the activity. In this case, the input fields become empty because you are navigating to the login fragment again for a split second.Florian
10/24/2020, 9:38 AMFlorian
10/24/2020, 9:38 AMLOGIN_SUCCESSFUL
flag). Is there anything wrong with this approach?