Skip to content

Fintasys/RxKotlin-GoogleApiClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Kotlin GoogleApiClient with RxKotlin

Easy handling of GoogleApiClient with RxKotlin

Usage

class TestClass(val context: Context) {

    companion object {
        val TAG = this::class.java.simpleName
    }

    private val googleApiHelperRx: GoogleApiHelperRx = GoogleApiHelperRx()

    fun doSomethingWithGoogleApi() {

        // Define ConnectionCallback which be called after GoogleApiClient connected successfully
        val connCallback = object : GoogleApiHelperRx.GoogleApiClientCallbackRx {
            override fun onConnected(client: GoogleApiClient, emitter: ObservableEmitter<GoogleApiClient>) {
                // Use emitter to control the flow
                Log.w(TAG, "do something cool")
                emitter.onComplete()

                // User client to disconnect from GoogleApiClient
                // client.disconnect()
            }

        }

        googleApiHelperRx.build(context, connCallback)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .doOnComplete {
                    Log.w(TAG, "onComplete")
                }
                .doOnError {
                    Log.w(TAG, "onError" + it.message)
                }
                .subscribe()
    }
}

About

Easy handling of GoogleApiClient with RxKotlin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages