Start BillingManager connection asynchronously

This commit is contained in:
Moez Bhatti
2018-09-22 00:28:45 -04:00
parent dc1263b16b
commit d43b4be57a
@@ -31,7 +31,9 @@ import com.android.billingclient.api.SkuDetails
import com.android.billingclient.api.SkuDetailsParams
import com.moez.QKSMS.BuildConfig
import com.moez.QKSMS.manager.AnalyticsManager
import io.reactivex.Flowable
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.BehaviorSubject
import io.reactivex.subjects.Subject
import timber.log.Timber
@@ -84,7 +86,7 @@ class BillingManager @Inject constructor(
private fun startServiceConnection(onSuccess: () -> Unit) {
billingClient.startConnection(object : BillingClientStateListener {
val listener = object : BillingClientStateListener {
override fun onBillingSetupFinished(@BillingResponse billingResponseCode: Int) {
if (billingResponseCode == BillingResponse.OK) {
isServiceConnected = true
@@ -98,7 +100,11 @@ class BillingManager @Inject constructor(
override fun onBillingServiceDisconnected() {
isServiceConnected = false
}
})
}
Flowable.fromCallable { billingClient.startConnection(listener) }
.subscribeOn(Schedulers.io())
.subscribe()
}
private fun querySkuDetailsAsync() {