当前位置: 首页>>代码示例>>Java>>正文


Java Inventory类代码示例

本文整理汇总了Java中com.android.vending.billing.Inventory的典型用法代码示例。如果您正苦于以下问题:Java Inventory类的具体用法?Java Inventory怎么用?Java Inventory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Inventory类属于com.android.vending.billing包,在下文中一共展示了Inventory类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getQueryListener

import com.android.vending.billing.Inventory; //导入依赖的package包/类
private IabHelper.QueryInventoryFinishedListener getQueryListener(final IabHelper helper) {
    return new IabHelper.QueryInventoryFinishedListener() {
        @Override
        public void onQueryInventoryFinished(IabResult result, Inventory inv) {
            if (result.isSuccess()) {
                inventory = inv;
                checkPurchase(R.string.sku_tasker, R.string.p_purchased_tasker);
                checkPurchase(R.string.sku_tesla_unread, R.string.p_purchased_tesla_unread);
                checkPurchase(R.string.sku_dashclock, R.string.p_purchased_dashclock);
                checkPurchase(R.string.sku_themes, R.string.p_purchased_themes);
                broadcaster.refresh();
            } else {
                Timber.e("query inventory failed: %s", result.getMessage());
            }
            helper.dispose();
        }
    };
}
 
开发者ID:andyCano,项目名称:TaskApp,代码行数:19,代码来源:InventoryHelper.java

示例2: onQueryInventoryFinished

import com.android.vending.billing.Inventory; //导入依赖的package包/类
@Override
public void onQueryInventoryFinished(@NonNull final IabResult result, @NonNull final Inventory inventory) {
	Log.d(TAG, "Query inventory finished - " + inventory);

	// Have we been disposed of in the meantime? If so, quit.
	if (mIabHelper == null) {
		return;
	}

	// Is it a failure?
	if (result.isFailure()) {
		Log.e(TAG, "Failed to query inventory: " + result);
		return;
	}

	Log.d(TAG, "Query inventory was successful.");

	List<PurchasedSku> purchases = new ArrayList<>();
	List<SkuDetails> nonPurchases = new ArrayList<>();
	for (String purchaseId : Arrays.asList(PRODUCT_IDS)) {
		Purchase purchase = inventory.getPurchase(purchaseId);
		SkuDetails skuDetails = inventory.getSkuDetails(purchaseId);

		if (purchase == null && skuDetails == null) {
			Log.w(TAG, "Did not find entry for " + purchaseId);
		}
		else {
			synchronized (GoogleBillingHelper.class) {
				if (purchase == null) {
					nonPurchases.add(skuDetails);
				}
				else {
					Log.d(TAG, "Found purchase: " + purchase);
					purchases.add(new PurchasedSku(skuDetails, purchase));
					if (Arrays.asList(PREMIUM_IDS).contains(purchase.getSku())) {
						mIsPremium = true;
					}
				}
			}
		}

	}

	if (mOnInventoryFinishedListener != null) {
		mOnInventoryFinishedListener.handleProducts(purchases, nonPurchases, mIsPremium);
	}
}
 
开发者ID:jeisfeld,项目名称:Augendiagnose,代码行数:48,代码来源:GoogleBillingHelper.java


注:本文中的com.android.vending.billing.Inventory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。