Skip to content

Instantly share code, notes, and snippets.

@macsystems
Last active January 22, 2020 11:47
Show Gist options
  • Save macsystems/ce7a0537b8a7085c24255bb8627aa8dc to your computer and use it in GitHub Desktop.
Save macsystems/ce7a0537b8a7085c24255bb8627aa8dc to your computer and use it in GitHub Desktop.
Using sealed class to change progressbar visibility
fun ProgressBar.handleState(resource: Resource<Any>) {
visibility = when (resource) {
is Loading -> View.VISIBLE
is Error -> View.GONE
is Success -> View.GONE
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment