Last active
February 26, 2019 03:44
-
-
Save apkelly/8dc7f5a62b1b49d9c2871fad245f7ade to your computer and use it in GitHub Desktop.
This file contains 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
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