Skip to content

Instantly share code, notes, and snippets.

@tolmachevroman
Last active November 26, 2017 05:16
Show Gist options
  • Save tolmachevroman/d94e541b38fea03bf8a3a4a0593dbd4c to your computer and use it in GitHub Desktop.
Save tolmachevroman/d94e541b38fea03bf8a3a4a0593dbd4c to your computer and use it in GitHub Desktop.
Medium Post 2. onMapLoaded()
override fun onMapLoaded() {
restaurantsViewModel.restaurants
.observe(this, Observer<Resource<List<Restaurant>>> { resource ->
when (resource?.status) {
Resource.Status.SUCCESS -> {
hideLoading()
if (resource.data != null && resource.data.isNotEmpty()) {
showMarkers(resource.data)
}
}
Resource.Status.ERROR -> {
hideLoading()
if (resource.error != null) {
showErrorMessage(resource.error)
}
}
Resource.Status.LOADING -> {
showLoading()
}
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment