Instantly share code, notes, and snippets.

Embed
What would you like to do?
private fun checkData() {
if (view == null) return
when (model.state) {
CREATED -> {
showProgress()
model.setListener { checkData() }
model.load()
}
PROGRESS -> {
showProgress()
model.setListener { checkData() }
}
ERROR -> {
showError(R.string.unable_to_load) {
showProgress()
model.setListener { checkData() }
model.load()
}
}
LOADED -> {
adapter.addItems(model.data.sortedBy { it.name })
showContent()
adapter.setOnclickListener { category ->
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment