mirror of
https://github.com/defold/extension-iap
synced 2025-06-27 10:27:46 +02:00
Null checks
This commit is contained in:
parent
a88fab1543
commit
3c5f8c1424
@ -184,11 +184,14 @@ public class IapGooglePlay implements PurchasesUpdatedListener {
|
|||||||
*/
|
*/
|
||||||
private List<Purchase> queryPurchases(final String type) {
|
private List<Purchase> queryPurchases(final String type) {
|
||||||
PurchasesResult result = billingClient.queryPurchases(type);
|
PurchasesResult result = billingClient.queryPurchases(type);
|
||||||
|
List<Purchase> purchases = result.getPurchasesList();
|
||||||
|
if (purchases == null) {
|
||||||
|
purchases = new ArrayList<Purchase>();
|
||||||
|
}
|
||||||
if (result.getBillingResult().getResponseCode() != BillingResponseCode.OK) {
|
if (result.getBillingResult().getResponseCode() != BillingResponseCode.OK) {
|
||||||
Log.e(TAG, "Unable to query pending purchases: " + result.getBillingResult().getDebugMessage());
|
Log.e(TAG, "Unable to query pending purchases: " + result.getBillingResult().getDebugMessage());
|
||||||
return new ArrayList<Purchase>();
|
|
||||||
}
|
}
|
||||||
return result.getPurchasesList();
|
return purchases;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -332,12 +335,14 @@ public class IapGooglePlay implements PurchasesUpdatedListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetails) {
|
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetails) {
|
||||||
// cache skus (cache will be used to speed up buying)
|
if (skuDetails != null) {
|
||||||
for (SkuDetails sd : skuDetails) {
|
// cache skus (cache will be used to speed up buying)
|
||||||
IapGooglePlay.this.products.put(sd.getSku(), sd);
|
for (SkuDetails sd : skuDetails) {
|
||||||
|
IapGooglePlay.this.products.put(sd.getSku(), sd);
|
||||||
|
}
|
||||||
|
// add to list of all sku details
|
||||||
|
allSkuDetails.addAll(skuDetails);
|
||||||
}
|
}
|
||||||
// add to list of all sku details
|
|
||||||
allSkuDetails.addAll(skuDetails);
|
|
||||||
// we're finished when we have queried for both in-app and subs
|
// we're finished when we have queried for both in-app and subs
|
||||||
queries--;
|
queries--;
|
||||||
if (queries == 0) {
|
if (queries == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user