Last active
September 9, 2021 17:06
-
-
Save ericntd/a76147651e102085923a9676a15a3d49 to your computer and use it in GitHub Desktop.
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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
setUpObservation() | |
} | |
private fun setUpObservation() { | |
viewModel.viewState.observe(this, Observer { state -> | |
when (state) { | |
is ProfileViewModel.ViewState.ProfileLoaded -> { | |
// render avatar, user name, photos etc. | |
} | |
is ProfileViewModel.ViewState.ProfileLoadFailure -> TODO() | |
ProfileViewModel.ViewState.Loading -> { | |
// render loading animation | |
} | |
} | |
}) | |
viewModel.actionState.observe(this, Observer { state -> | |
when (state) { | |
ProfileViewModel.ActionState.NeedsVerification -> { | |
// navigation to Verification screen | |
} | |
ProfileViewModel.ActionState.NeedsLogOut -> { | |
// Clear data, finish this activity and navigate to LogIn screen? | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment