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();
}
}
}
}
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));
}
Aggregations