Skip to content

Instantly share code, notes, and snippets.

@apkelly
Last active February 26, 2019 03:44
Show Gist options
  • Save apkelly/8dc7f5a62b1b49d9c2871fad245f7ade to your computer and use it in GitHub Desktop.
Save apkelly/8dc7f5a62b1b49d9c2871fad245f7ade to your computer and use it in GitHub Desktop.
private lateinit var mViewModel: CloudAutoMLViewModel
override fun onCreate(icicle: Bundle?) {
super.onCreate(icicle)
mViewModel = ViewModelProviders.of(this).get(CloudAutoMLViewModel::class.java)
mViewModel.subscribeClassifications()
.observe(this, Observer<Resource<Pair<Int, String>, Throwable>> { resource ->
when (resource) {
is LoadingResource -> {
// TODO show a loading indicator
}
is SuccessResource -> {
// We have a name for a given face id.
val faceId = resource.data.first
val name = resource.data.second
(mGraphicOverlay.find(faceId) as? FaceGraphic)?.setName(name)
}
is ErrorResource -> {
// Just print errors to stdout for now.
resource.errorData?.printStackTrace()
}
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment