override fun onSkuDetailsResponse()

in ClassyTaxiAppKotlin/app/src/main/java/com/example/subscriptions/billing/BillingClientLifecycle.kt [149:199]


    override fun onSkuDetailsResponse(
            billingResult: BillingResult,
            skuDetailsList: MutableList<SkuDetails>?) {
        val responseCode = billingResult.responseCode
        val debugMessage = billingResult.debugMessage
        when (responseCode) {
            BillingClient.BillingResponseCode.OK -> {
                Log.i(TAG, "onSkuDetailsResponse: $responseCode $debugMessage")
                val expectedSkuDetailsCount = LIST_OF_SKUS.size
                if (skuDetailsList == null) {
                    skusWithSkuDetails.postValue(emptyMap())
                    Log.e(TAG, "onSkuDetailsResponse: " +
                            "Expected ${expectedSkuDetailsCount}, " +
                            "Found null SkuDetails. " +
                            "Check to see if the SKUs you requested are correctly published " +
                            "in the Google Play Console.")
                } else
                    skusWithSkuDetails.postValue(HashMap<String, SkuDetails>().apply {
                        for (details in skuDetailsList) {
                            put(details.sku, details)
                        }
                    }.also { postedValue ->
                        val skuDetailsCount = postedValue.size
                        if (skuDetailsCount == expectedSkuDetailsCount) {
                            Log.i(TAG, "onSkuDetailsResponse: Found $skuDetailsCount SkuDetails")
                        } else {
                            Log.e(TAG, "onSkuDetailsResponse: " +
                                    "Expected ${expectedSkuDetailsCount}, " +
                                    "Found $skuDetailsCount SkuDetails. " +
                                    "Check to see if the SKUs you requested are correctly published " +
                                    "in the Google Play Console.")
                        }
                    })
            }
            BillingClient.BillingResponseCode.SERVICE_DISCONNECTED,
            BillingClient.BillingResponseCode.SERVICE_UNAVAILABLE,
            BillingClient.BillingResponseCode.BILLING_UNAVAILABLE,
            BillingClient.BillingResponseCode.ITEM_UNAVAILABLE,
            BillingClient.BillingResponseCode.DEVELOPER_ERROR,
            BillingClient.BillingResponseCode.ERROR -> {
                Log.e(TAG, "onSkuDetailsResponse: $responseCode $debugMessage")
            }
            BillingClient.BillingResponseCode.USER_CANCELED,
            BillingClient.BillingResponseCode.FEATURE_NOT_SUPPORTED,
            BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED,
            BillingClient.BillingResponseCode.ITEM_NOT_OWNED -> {
                // These response codes are not expected.
                Log.wtf(TAG, "onSkuDetailsResponse: $responseCode $debugMessage")
            }
        }
    }