Skip to content

Instantly share code, notes, and snippets.

@sanogueralorenzo
Last active November 6, 2018 14:26
Show Gist options
  • Save sanogueralorenzo/a71c009504ac8bbece4c497e28d57350 to your computer and use it in GitHub Desktop.
Save sanogueralorenzo/a71c009504ac8bbece4c497e28d57350 to your computer and use it in GitHub Desktop.
private fun updateUsers(resource: Resource<List<Users>>?) {
resource?.let {
when (it.state) {
ResourceState.LOADING -> loading.visible()
ResourceState.SUCCESS -> loading.gone()
ResourceState.ERROR -> loading.gone()
}
it.data?.let { adapter.addItems(it) }
it.message?.let { snackBar.show() }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment