use of com.codename1.payments.v3.IabException in project CodenameOne by codenameone.
the class CodenameOneActivity method getProducts.
Product[] getProducts(String[] skus, boolean fromCacheOnly) {
if (inventory != null) {
ArrayList pList = new ArrayList<Product>();
ArrayList moreskusList = new ArrayList<Product>();
for (int i = 0; i < skus.length; i++) {
String sku = skus[i];
if (inventory.hasDetails(sku)) {
SkuDetails details = inventory.getSkuDetails(sku);
Product p = new Product();
p.setSku(sku);
p.setDescription(details.getDescription());
p.setDisplayName(details.getTitle());
p.setLocalizedPrice(details.getPrice());
pList.add(p);
} else {
moreskusList.add(sku);
}
}
// if the inventory does not all the requestes sku make an update.
if (moreskusList.size() > 0 && !fromCacheOnly) {
try {
inventory = mHelper.queryInventory(true, moreskusList);
return getProducts(skus, true);
} catch (IabException ex) {
Logger.getLogger(CodenameOneActivity.class.getName()).log(Level.SEVERE, null, ex);
}
}
Product[] products = new Product[pList.size()];
products = (Product[]) pList.toArray(products);
return products;
}
return null;
}
Aggregations