Fix showing login/logout button on initial screens

This commit is contained in:
Kirill Kamakin
2022-04-04 19:34:21 +05:00
parent c98feceab4
commit fb10333c2c
5 changed files with 59 additions and 63 deletions

View File

@@ -27,7 +27,8 @@ class RecipesFragment : Fragment(R.layout.fragment_recipes) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
authViewModel.authenticationState.observe(this, ::onAuthStateChange)
Timber.v("onCreate() called with: savedInstanceState = $savedInstanceState")
authViewModel.authenticationStateLive.observe(this, ::onAuthStateChange)
}
private fun onAuthStateChange(authenticationState: AuthenticationState) {
@@ -40,6 +41,7 @@ class RecipesFragment : Fragment(R.layout.fragment_recipes) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Timber.v("onViewCreated() called with: view = $view, savedInstanceState = $savedInstanceState")
authViewModel.showLoginButton = true
setupRecipeAdapter()
(requireActivity() as? AppCompatActivity)?.supportActionBar?.title = null
}
@@ -78,5 +80,6 @@ class RecipesFragment : Fragment(R.layout.fragment_recipes) {
Timber.v("onDestroyView() called")
// Prevent RV leaking through mObservers list in adapter
binding.recipes.adapter = null
authViewModel.showLoginButton = false
}
}