Search in sources :

Example 1 with BillingSkuDetails

use of com.litekite.monetize.room.entity.BillingSkuDetails in project Android-InAppBilling by LiteKite.

the class BillingPremiumVM method onClick.

/**
 * Handles Click Events from View.
 *
 * @param v A view in which the click action performed.
 */
public void onClick(@NonNull View v) {
    if (v.getId() == R.id.btn_billing_buy) {
        // Billing Library.
        if (premiumSkuDetails.getValue() != null) {
            BillingSkuDetails billingSkuDetails = premiumSkuDetails.getValue();
            try {
                SkuDetails skuDetails = new SkuDetails(billingSkuDetails.originalJson);
                Activity activityContext = ContextUtil.getActivity(v.getContext());
                if (activityContext != null) {
                    billingManager.initiatePurchaseFlow(activityContext, skuDetails);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : SkuDetails(com.android.billingclient.api.SkuDetails) BillingSkuDetails(com.litekite.monetize.room.entity.BillingSkuDetails) Activity(android.app.Activity) JSONException(org.json.JSONException) BillingSkuDetails(com.litekite.monetize.room.entity.BillingSkuDetails)

Example 2 with BillingSkuDetails

use of com.litekite.monetize.room.entity.BillingSkuDetails in project Android-InAppBilling by LiteKite.

the class BillingManager method storeSkuDetailsLocally.

/**
 * Stores SKU Details on local storage.
 *
 * @param skuDetailsMap Map of SKU Details returned from the queries.
 */
private void storeSkuDetailsLocally(Map<String, SkuDetails> skuDetailsMap) {
    final List<BillingSkuDetails> billingSkuDetailsList = new ArrayList<>();
    for (String key : skuDetailsMap.keySet()) {
        final SkuDetails skuDetail = skuDetailsMap.get(key);
        if (skuDetail != null) {
            BillingSkuDetails billingSkuDetails = new BillingSkuDetails();
            billingSkuDetails.skuID = skuDetail.getSku();
            billingSkuDetails.skuType = skuDetail.getType().equals(SkuType.SUBS) ? SkuType.SUBS : SkuType.INAPP;
            billingSkuDetails.skuPrice = skuDetail.getPrice();
            billingSkuDetails.originalJson = skuDetail.getOriginalJson();
            billingSkuDetailsList.add(billingSkuDetails);
        }
    }
    workExecutor.execute(() -> appDatabase.insertSkuDetails(billingSkuDetailsList));
}
Also used : BillingSkuDetails(com.litekite.monetize.room.entity.BillingSkuDetails) SkuDetails(com.android.billingclient.api.SkuDetails) ArrayList(java.util.ArrayList) BillingSkuDetails(com.litekite.monetize.room.entity.BillingSkuDetails)

Aggregations

SkuDetails (com.android.billingclient.api.SkuDetails)2 BillingSkuDetails (com.litekite.monetize.room.entity.BillingSkuDetails)2 Activity (android.app.Activity)1 ArrayList (java.util.ArrayList)1 JSONException (org.json.JSONException)1