in ClassyTaxiJava/app/src/main/java/com/sample/android/classytaxijava/billing/BillingClientLifecycle.java [149:204]
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList) {
if (billingResult == null) {
Log.wtf(TAG, "onSkuDetailsResponse: null BillingResult");
return;
}
int responseCode = billingResult.getResponseCode();
String debugMessage = billingResult.getDebugMessage();
switch (responseCode) {
case BillingClient.BillingResponseCode.OK:
Log.i(TAG, "onSkuDetailsResponse: " + responseCode + " " + debugMessage);
final int expectedSkuDetailsCount = LIST_OF_SKUS.size();
if (skuDetailsList == null) {
skusWithSkuDetails.postValue(Collections.<String, SkuDetails>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 {
Map<String, SkuDetails> newSkusDetailList = new HashMap<String, SkuDetails>();
for (SkuDetails skuDetails : skuDetailsList) {
newSkusDetailList.put(skuDetails.getSku(), skuDetails);
}
skusWithSkuDetails.postValue(newSkusDetailList);
int skuDetailsCount = newSkusDetailList.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.");
}
}
break;
case BillingClient.BillingResponseCode.SERVICE_DISCONNECTED:
case BillingClient.BillingResponseCode.SERVICE_UNAVAILABLE:
case BillingClient.BillingResponseCode.BILLING_UNAVAILABLE:
case BillingClient.BillingResponseCode.ITEM_UNAVAILABLE:
case BillingClient.BillingResponseCode.DEVELOPER_ERROR:
case BillingClient.BillingResponseCode.ERROR:
Log.e(TAG, "onSkuDetailsResponse: " + responseCode + " " + debugMessage);
break;
case BillingClient.BillingResponseCode.USER_CANCELED:
Log.i(TAG, "onSkuDetailsResponse: " + responseCode + " " + debugMessage);
break;
// These response codes are not expected.
case BillingClient.BillingResponseCode.FEATURE_NOT_SUPPORTED:
case BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED:
case BillingClient.BillingResponseCode.ITEM_NOT_OWNED:
default:
Log.wtf(TAG, "onSkuDetailsResponse: " + responseCode + " " + debugMessage);
}
}