Skip to content

Instantly share code, notes, and snippets.

@dkhmelenko
Created February 4, 2019 14:34
Show Gist options
  • Save dkhmelenko/4833d39283b715d50330d5714b885a85 to your computer and use it in GitHub Desktop.
Save dkhmelenko/4833d39283b715d50330d5714b885a85 to your computer and use it in GitHub Desktop.
lateinit var googleApiClient: GoogleApiClient
private var googleApiClientSubject = PublishSubject.create<GoogleApiClient>()
fun init() {
googleApiClient = GoogleApiClient.Builder(context)
.addConnectionCallbacks(object : GoogleApiClient.ConnectionCallbacks {
override fun onConnected(connectionHint: Bundle?) {
googleApiClientSubject.onNext(googleApiClient!!)
}
override fun onConnectionSuspended(cause: Int) {
googleApiClientSubject.onError(Exception("GoogleApiClient connection suspended,: $cause"))
}
})
.addApi(Auth.CREDENTIALS_API)
.build()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment