Last active
September 9, 2021 17:06
-
-
Save ericntd/f5ac7b5c3c14b2438f1683fc07a58e52 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. | |
textViewName.text = state.profile.name | |
// ... | |
} | |
is ProfileViewModel.ViewState.ProfileLoadFailure -> { | |
// render error layout with icon, error messages | |
} | |
ProfileViewModel.ViewState.Loading -> { | |
// render loading animation | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment