mirror of
https://github.com/defold/extension-iap
synced 2025-06-27 02:17:51 +02:00
Added null checks
This commit is contained in:
parent
f97a7ee6b6
commit
d74c97d5c7
@ -362,11 +362,15 @@ public class IapGooglePlay implements PurchasesUpdatedListener {
|
||||
*/
|
||||
@Override
|
||||
public void onPurchasesUpdated(BillingResult billingResult, List<Purchase> purchases) {
|
||||
if (billingResult.getResponseCode() == BillingResponseCode.OK && purchases != null) {
|
||||
if (billingResult.getResponseCode() == BillingResponseCode.OK) {
|
||||
if (purchases != null && !purchases.isEmpty()) {
|
||||
for (Purchase purchase : purchases) {
|
||||
if (purchase != null) {
|
||||
handlePurchase(purchase, this.purchaseListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.purchaseListener.onPurchaseResult(billingResultToDefoldResponse(billingResult), "");
|
||||
}
|
||||
@ -413,7 +417,12 @@ public class IapGooglePlay implements PurchasesUpdatedListener {
|
||||
@Override
|
||||
public void onProductDetailsResponse(BillingResult billingResult, List<ProductDetails> productDetailsList) {
|
||||
if (billingResult.getResponseCode() == BillingResponseCode.OK && (productDetailsList != null) && !productDetailsList.isEmpty()) {
|
||||
buyProduct(productDetailsList.get(0), token, purchaseListener);
|
||||
for (ProductDetails productDetails : productDetailsList) {
|
||||
if (productDetails != null) {
|
||||
buyProduct(productDetails, token, purchaseListener);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, "Unable to get product details before buying: " + billingResult.getDebugMessage());
|
||||
@ -435,11 +444,13 @@ public class IapGooglePlay implements PurchasesUpdatedListener {
|
||||
|
||||
@Override
|
||||
public void onProductDetailsResponse(BillingResult billingResult, List<ProductDetails> productDetails) {
|
||||
if (productDetails != null) {
|
||||
if (productDetails != null && !productDetails.isEmpty()) {
|
||||
// cache products (cache will be used to speed up buying)
|
||||
for (ProductDetails pd : productDetails) {
|
||||
if (pd != null) {
|
||||
IapGooglePlay.this.products.put(pd.getProductId(), pd);
|
||||
}
|
||||
}
|
||||
// add to list of all product details
|
||||
allProductDetails.addAll(productDetails);
|
||||
}
|
||||
@ -485,11 +496,13 @@ public class IapGooglePlay implements PurchasesUpdatedListener {
|
||||
@Override
|
||||
public void onProductDetailsResponse(BillingResult billingResult, List<ProductDetails> productDetails) {
|
||||
JSONArray a = new JSONArray();
|
||||
if (billingResult.getResponseCode() == BillingResponseCode.OK) {
|
||||
if ((billingResult.getResponseCode() == BillingResponseCode.OK) && (productDetails != null) && !productDetails.isEmpty()) {
|
||||
for (ProductDetails pd : productDetails) {
|
||||
if (pd != null) {
|
||||
a.put(convertProductDetails(pd));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, "Unable to list products: " + billingResult.getDebugMessage());
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ target_sdk_version = 29
|
||||
|
||||
[project]
|
||||
title = extension-iap
|
||||
dependencies = https://github.com/andsve/dirtylarry/archive/master.zip
|
||||
dependencies#0 = https://github.com/andsve/dirtylarry/archive/master.zip
|
||||
|
||||
[library]
|
||||
include_dirs = extension-iap
|
||||
|
Loading…
x
Reference in New Issue
Block a user