Created
April 16, 2018 15:39
-
-
Save n-belokopytov/f4628408dd0ce106eb102a517593849d to your computer and use it in GitHub Desktop.
State Machine in View with a Sealed Class from Kotlin
This file contains hidden or 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 onStart() { | |
viewModel.tabbedListLiveData.observe(this, Observer { | |
when (it) { | |
is ErrorState -> { | |
showProgress(false) | |
showErrorView(it.errorMessage, it.errorColor) | |
} | |
is InProgressState -> showProgress(true) | |
is OfflineState -> { | |
showProgress(false) | |
displayList(it.listElements) | |
hideTabs() | |
} | |
is ListState -> { | |
showProgress(false) | |
displayList(it.listElements, it.totalItems) | |
displayTabs(it.currentTabId, it.tabs) | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment