本文整理汇总了Java中com.amazon.device.iap.model.Product类的典型用法代码示例。如果您正苦于以下问题:Java Product类的具体用法?Java Product怎么用?Java Product使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Product类属于com.amazon.device.iap.model包,在下文中一共展示了Product类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onProductDataResponse
import com.amazon.device.iap.model.Product; //导入依赖的package包/类
@Override
public void onProductDataResponse(ProductDataResponse response) {
final ProductDataResponse.RequestStatus status = response.getRequestStatus();
logDebug("onProductDataResponse: RequestStatus (" + status + ")");
switch (status) {
case SUCCESSFUL:
logDebug("onProductDataResponse: successful. The item data map in this response includes the valid SKUs");
final Set<String> unavailableSkus = response.getUnavailableSkus();
logDebug("onProductDataResponse: " + unavailableSkus.size() + " unavailable skus");
Map<String, Product> productData = response.getProductData();
logDebug("onProductDataResponse productData : " + productData.size());
Map<String, String> iapkeyPrices = new HashMap<>();
for (Map.Entry<String, Product> entry : productData.entrySet()) {
Product product = productData.get(entry.getKey());
iapkeyPrices.put(product.getSku(), product.getPrice());
}
amazonBillingService.updatePrices(iapkeyPrices);
break;
case FAILED:
case NOT_SUPPORTED:
logDebug("onProductDataResponse: failed, should retry request");
break;
}
}
开发者ID:eggheadgames,项目名称:android-in-app-payments,代码行数:27,代码来源:AmazonBillingListener.java
示例2: getSkusDetails
import com.amazon.device.iap.model.Product; //导入依赖的package包/类
@NonNull
public static Collection<SkuDetails> getSkusDetails(
@NonNull final ProductDataResponse response) {
final Collection<SkuDetails> skusDetails = new ArrayList<>();
final Collection<Product> products = response.getProductData().values();
for (final Product product : products) {
final SkuDetails skuDetails = convertSkuDetails(product);
if (skuDetails != null) {
skusDetails.add(skuDetails);
}
}
for (final String sku : response.getUnavailableSkus()) {
skusDetails.add(new SkuDetails(sku));
}
return skusDetails;
}
开发者ID:onepf,项目名称:OPFIab,代码行数:19,代码来源:AmazonUtils.java
示例3: onProductDataResponse
import com.amazon.device.iap.model.Product; //导入依赖的package包/类
@Override
public void onProductDataResponse(@NotNull final ProductDataResponse productDataResponse) {
final ProductDataResponse.RequestStatus status = productDataResponse.getRequestStatus();
final RequestId requestId = productDataResponse.getRequestId();
Logger.d("onItemDataResponse() reqStatus: ", status,
", reqId: ", requestId);
switch (status) {
case SUCCESSFUL:
final Map<String, Product> productData = productDataResponse.getProductData();
for (final String key : productData.keySet()) {
final Product product = productData.get(key);
inventory.addSkuDetails(getSkuDetails(product));
}
break;
case FAILED:
// Fall through
case NOT_SUPPORTED:
break;
}
final CountDownLatch countDownLatch = inventoryLatchQueue.poll();
if (countDownLatch != null) {
countDownLatch.countDown();
}
}
开发者ID:onepf,项目名称:OpenIAB,代码行数:26,代码来源:AmazonAppstoreBillingService.java
示例4: getSkuDetails
import com.amazon.device.iap.model.Product; //导入依赖的package包/类
@NotNull
private SkuDetails getSkuDetails(@NotNull final Product product) {
final String sku = product.getSku();
final String price = product.getPrice().toString();
final String title = product.getTitle();
final String description = product.getDescription();
final ProductType productType = product.getProductType();
Logger.d(String.format("Item: %s\n Type: %s\n SKU: %s\n Price: %s\n Description: %s\n",
title, productType, sku, price, description));
final String openIabSkuType = productType == ProductType.SUBSCRIPTION
? IabHelper.ITEM_TYPE_SUBS
: IabHelper.ITEM_TYPE_INAPP;
final String openIabSku = SkuManager.getInstance().getSku(OpenIabHelper.NAME_AMAZON, sku);
return new SkuDetails(openIabSkuType, openIabSku, title, price, description);
}
开发者ID:onepf,项目名称:OpenIAB,代码行数:17,代码来源:AmazonAppstoreBillingService.java
示例5: convertProductToInformation
import com.amazon.device.iap.model.Product; //导入依赖的package包/类
/** Converts a Product to our Information object. */
static Information convertProductToInformation(Product product) {
String priceString = product.getPrice();
return Information.newBuilder()
.localName(product.getTitle())
.localDescription(product.getDescription())
.localPricing(priceString)
.priceCurrencyCode(tryParseCurrency(priceString))
.priceInCents(tryParsePriceInCents(priceString))
.build();
}
开发者ID:libgdx,项目名称:gdx-pay,代码行数:13,代码来源:AmazonTransactionUtils.java
示例6: onProductDataResponse
import com.amazon.device.iap.model.Product; //导入依赖的package包/类
/**
* This is the callback for {@link PurchasingService#getProductData}.
*/
@Override
public void onProductDataResponse(final ProductDataResponse response) {
final ProductDataResponse.RequestStatus status = response.getRequestStatus();
showMessage(LOGTYPELOG, "onProductDataResponse: RequestStatus (" + status + ")");
switch (status) {
case SUCCESSFUL:
showMessage(LOGTYPELOG, "onProductDataResponse: successful");
// Store product information
Map<String, Product> availableSkus = response.getProductData();
showMessage(LOGTYPELOG, "onProductDataResponse: " + availableSkus.size() + " available skus");
for (Entry<String, Product> entry : availableSkus.entrySet()) {
informationMap.put(entry.getKey(), AmazonTransactionUtils.convertProductToInformation(entry.getValue()));
}
final Set<String> unavailableSkus = response.getUnavailableSkus();
showMessage(LOGTYPELOG, "onProductDataResponse: " + unavailableSkus.size() + " unavailable skus");
for (String sku : unavailableSkus) {
showMessage(LOGTYPELOG, "onProductDataResponse: sku " + sku + " is not available");
}
break;
case FAILED:
case NOT_SUPPORTED:
showMessage(LOGTYPEERROR, "onProductDataResponse: failed, should retry request");
break;
}
}
开发者ID:libgdx,项目名称:gdx-pay,代码行数:33,代码来源:PurchaseManagerAndroidAmazon.java
示例7: convertSkuDetails
import com.amazon.device.iap.model.Product; //导入依赖的package包/类
/**
* Transforms Amazon product into library SKU details model.
*
* @param product Amazon product to transform.
*
* @return Newly constructed SkuDetails object.
*/
@Nullable
public static SkuDetails convertSkuDetails(@NonNull final Product product) {
final String originalJson;
try {
originalJson = product.toJSON().toString();
} catch (JSONException exception) {
OPFLog.e("Failed to set original JSON for SkuDetails.", exception);
return null;
}
final SkuDetails.Builder builder = new SkuDetails.Builder(product.getSku());
final ProductType productType = product.getProductType();
switch (productType) {
case CONSUMABLE:
builder.setType(SkuType.CONSUMABLE);
break;
case ENTITLED:
builder.setType(SkuType.ENTITLEMENT);
break;
case SUBSCRIPTION:
builder.setType(SkuType.SUBSCRIPTION);
break;
default:
OPFLog.e("Unknown Amazon product type: " + productType);
return null;
}
builder.setTitle(product.getTitle());
builder.setDescription(product.getDescription());
builder.setPrice(product.getPrice());
builder.setProviderName(AmazonBillingProvider.NAME);
builder.setOriginalJson(originalJson);
return builder.build();
}
开发者ID:onepf,项目名称:OPFIab,代码行数:41,代码来源:AmazonUtils.java
示例8: AmazonSkuDetails
import com.amazon.device.iap.model.Product; //导入依赖的package包/类
public AmazonSkuDetails(@NonNull final String originalJson) throws JSONException {
super(originalJson);
final ProductType productType = ProductType.valueOf(jsonObject.getString(NAME_ITEM_TYPE));
if (productType == null) {
throw new JSONException("Unknown product type.");
}
final ProductBuilder builder = new ProductBuilder()
.setSku(sku)
.setTitle(jsonObject.getString(NAME_TITLE))
.setDescription(jsonObject.getString(NAME_DESCRIPTION))
.setPrice(jsonObject.getString(NAME_PRICE))
.setSmallIconUrl(jsonObject.getString(NAME_SMALL_ICON_URL));
builder.setProductType(productType);
this.product = new Product(builder);
}
开发者ID:onepf,项目名称:OPFIab,代码行数:16,代码来源:AmazonSkuDetails.java
示例9: onProductDataResponse
import com.amazon.device.iap.model.Product; //导入依赖的package包/类
/**
* see parent (or https://developer.amazon.com/public/apis/earn/in-app-purchasing/docs/quick-start)
*/
@Override
public void onProductDataResponse(ProductDataResponse productDataResponse) {
IabResult result = null;
switch (productDataResponse.getRequestStatus()) {
case SUCCESSFUL:
String unskus = "";
for (final String s : productDataResponse.getUnavailableSkus()) {
unskus += s + "/";
}
if (!TextUtils.isEmpty(unskus)) {
Log.d(TAG, "(onItemDataResponse) The following skus were unavailable: " + unskus);
}
final Map<String, Product> products = productDataResponse.getProductData();
for (final String key : products.keySet()) {
Product product = products.get(key);
String currencyCode = "";
long priceMicros = 0;
SkuDetails skuDetails = new SkuDetails(ITEM_TYPE_INAPP,
product.getSku(), product.getPrice(), product.getTitle(), product.getDescription(), priceMicros, currencyCode);
mInventory.addSkuDetails(skuDetails);
Log.d(TAG, String.format("Product: %s\n Type: %s\n SKU: %s\n Price: %s\n Description: %s\n",
product.getTitle(), product.getProductType(), product.getSku(), product.getPrice(), product.getDescription()));
}
result = new IabResult(BillingResponse.BILLING_RESPONSE_RESULT_OK,"");
break;
case FAILED: // Fail gracefully on failed responses.
result = new IabResult(BillingResponse.BILLING_RESPONSE_RESULT_ERROR,
"Couldn't complete refresh operation.");
// Log.v(TAG, "ItemDataRequestStatus: FAILED");
break;
}
mLastResult = result;
synchronized(mLock) {
mLock.notify();
}
}
开发者ID:archos-sa,项目名称:aos-Video,代码行数:47,代码来源:AmazonIabHelper.java
示例10: onProductDataResponse
import com.amazon.device.iap.model.Product; //导入依赖的package包/类
@Override
public void onProductDataResponse(ProductDataResponse response) {
final ArrayList<InAppProduct> products = new ArrayList<InAppProduct>();
Error error = null;
switch (response.getRequestStatus()) {
case SUCCESSFUL:
Map<String, Product> items = response.getProductData();
for (String key : items.keySet()) {
Product i = items.get(key);
InAppProduct product = new InAppProduct();
product.productId = i.getSku();
product.title = i.getTitle();
product.description = i.getDescription();
String localizedPrice = i.getPrice();
String price = localizedPrice.replaceAll("[^\\d.]", "");
try {
product.price = Double.parseDouble(price);
}
catch (Exception ex) {
ex.printStackTrace();
}
product.localizedPrice = localizedPrice;
products.add(product);
}
break;
case FAILED:
error = new Error(0, "Products information could not be retrieved");
break;
case NOT_SUPPORTED:
error = new Error(0, "Products information not supported");
break;
}
final Error finalError = error;
dispatchCallback(new Runnable() {
@Override
public void run() {
mFetchCallback.onComplete(products, finalError);
mFetchCallback = null;
}
});
}
开发者ID:ludei,项目名称:atomic-plugins-inapps,代码行数:49,代码来源:AmazonInAppService.java
示例11: onProductDataResponse
import com.amazon.device.iap.model.Product; //导入依赖的package包/类
/**
* see parent (or https://developer.amazon.com/public/apis/earn/in-app-purchasing/docs/quick-start)
*/
@Override
public void onProductDataResponse(ProductDataResponse productDataResponse) {
switch (productDataResponse.getRequestStatus()) {
case SUCCESSFUL:
String unskus = "";
for (final String s : productDataResponse.getUnavailableSkus()) {
unskus += s + "/";
}
if (!TextUtils.isEmpty(unskus)) {
SoomlaUtils.LogError(TAG, "(onItemDataResponse) The following skus were unavailable: " + unskus);
}
final Map<String, Product> products = productDataResponse.getProductData();
IabInventory inventory = new IabInventory();
for (final String key : products.keySet()) {
Product product = products.get(key);
String currencyCode = AmazonIabUtils.getCurrencyCode(mCurrentUserData.getMarketplace());
long priceMicros = AmazonIabUtils.getPriceAmountMicros(product.getPrice());
IabSkuDetails skuDetails = new IabSkuDetails(ITEM_TYPE_INAPP,
product.getSku(), product.getPrice(), product.getTitle(), product.getDescription(), priceMicros, currencyCode);
inventory.addSkuDetails(skuDetails);
SoomlaUtils.LogDebug(TAG, String.format("Product: %s\n Type: %s\n SKU: %s\n Price: %s\n Description: %s\n",
product.getTitle(), product.getProductType(), product.getSku(), product.getPrice(), product.getDescription()));
}
AmazonIabHelper.this.fetchSkusDetailsSuccess(inventory);
break;
case FAILED: // Fail gracefully on failed responses.
IabResult result = new IabResult(IabResult.BILLING_RESPONSE_RESULT_ERROR,
"Couldn't complete refresh operation.");
AmazonIabHelper.this.fetchSkusDetailsFailed(result);
// Log.v(TAG, "ItemDataRequestStatus: FAILED");
break;
}
}
开发者ID:soomla,项目名称:android-store-amazon,代码行数:45,代码来源:AmazonIabHelper.java
注:本文中的com.amazon.device.iap.model.Product类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论