use of com.android.billingclient.api.PurchaseHistoryResponseListener in project Android-InAppBilling by LiteKite.
the class BillingManager method queryPurchaseHistoryAsync.
/**
* Queries InApp and Subscribed purchase results from Google Play Remote Server.
*
* @param purchasesResultList this list contains all the product purchases made, has InApp and
* Subscription purchased results.
* @param skuType InApp or Subscription.
* @param executeWhenFinished Once the InApp product purchase results are given, then
* subscription based purchase results are queried and results are
* placed into the {@link #myPurchasesResultList}
*/
private void queryPurchaseHistoryAsync(final List<Purchase> purchasesResultList, @SkuType final String skuType, final Runnable executeWhenFinished) {
Runnable queryPurchases = new Runnable() {
@Override
public void run() {
myBillingClient.queryPurchaseHistoryAsync(skuType, new PurchaseHistoryResponseListener() {
@Override
public void onPurchaseHistoryResponse(@BillingResponse int responseCode, List<Purchase> purchasesList) {
if (responseCode == BillingResponse.OK && purchasesList != null) {
purchasesResultList.addAll(purchasesList);
if (executeWhenFinished != null) {
executeWhenFinished.run();
}
} else {
BaseActivity.printLog(TAG, "queryPurchases() got an error response code: " + responseCode);
logErrorType(responseCode);
}
if (executeWhenFinished == null) {
onQueryPurchasesFinished(purchasesResultList, responseCode);
}
}
});
}
};
executeServiceRequest(queryPurchases);
}
use of com.android.billingclient.api.PurchaseHistoryResponseListener in project Android-InAppBilling by LiteKite.
the class BillingManager method queryPurchaseHistoryAsync.
/**
* Queries InApp and Subscribed purchase results from Google Play Remote Server.
*
* @param purchases this list contains all the product purchases made, has InApp and
* Subscription purchased results.
* @param skuType InApp or Subscription.
* @param executeWhenFinished Once the InApp product purchase results are given, then
* subscription based purchase results are queried and results are placed into the {@link
* #myPurchasesResultList}
*/
private void queryPurchaseHistoryAsync(final List<PurchaseHistoryRecord> purchases, @SkuType final String skuType, final Runnable executeWhenFinished) {
PurchaseHistoryResponseListener listener = (billingResult, list) -> {
if (billingResult.getResponseCode() == BillingResponseCode.OK && list != null) {
purchases.addAll(list);
if (executeWhenFinished != null) {
executeWhenFinished.run();
}
} else {
MonetizeApp.printLog(TAG, "queryPurchaseHistoryAsync() got an error response code: " + billingResult.getResponseCode());
logErrorType(billingResult);
}
if (executeWhenFinished == null) {
storePurchaseHistoryRecordsLocally(purchases);
}
};
executeServiceRequest(() -> myBillingClient.queryPurchaseHistoryAsync(skuType, listener));
}
Aggregations