Skip to content

Instantly share code, notes, and snippets.

@gastsail
Last active March 5, 2020 23:18
Show Gist options
  • Save gastsail/c43d559c49f2264a03ecc2d6d39576e4 to your computer and use it in GitHub Desktop.
Save gastsail/c43d559c49f2264a03ecc2d6d39576e4 to your computer and use it in GitHub Desktop.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
observeData()
}
private fun observeData(){
viewModel.fetchVersionCode.observe(this, Observer { result ->
when(result){
is Resource.Loading -> {
showProgress()
}
is Resource.Success -> {
val actualVersion = result.data
Toast.makeText(this,"Version: ${result.data}",Toast.LENGTH_SHORT).show()
if(appIsOutDated(actualVersion)){
showUpdateProgress()
}
hideProgress()
}
is Resource.Failure -> {
Toast.makeText(this,"Error ${result.exception.message}",Toast.LENGTH_SHORT).show()
hideProgress()
}
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment