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


Java Offer类代码示例

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


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

示例1: shouldCallPurchaseCallbackErrorWhenPurcharseIntentSenderForResultFails

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
@Test
public void shouldCallPurchaseCallbackErrorWhenPurcharseIntentSenderForResultFails() throws Exception {
    activityBindAndConnect();

    Offer offer = offerFullEditionEntitlement();

    whenGetBuyIntentForIdentifierReturn(offer.getIdentifier(), buyIntentResponseOk());

    doThrow(new IntentSender.SendIntentException("Intent cancelled")).when(applicationProxy)
            .startIntentSenderForResult(isA(IntentSender.class),
                    eq(ACTIVITY_REQUEST_CODE), isA(Intent.class), eq(0), eq(0), eq(0));
    v3InAppbillingService.startPurchaseRequest(offer.getIdentifier(), PURCHASE_TYPE_IN_APP, purchaseRequestCallback);

    verify(applicationProxy).startIntentSenderForResult(isA(IntentSender.class),
            eq(ACTIVITY_REQUEST_CODE), isA(Intent.class), eq(0), eq(0), eq(0));

    verify(purchaseRequestCallback).purchaseError(isA(GdxPayException.class));
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:19,代码来源:V3GoogleInAppBillingServiceTest.java

示例2: refreshSKUs

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
private void refreshSKUs() {
 		// refresh the identifiers/SKUs: ensures we have the correct mapping in case PurchaseManagerConfig was updated
	if (config == null) return;
 		for (int i = 0; i < config.getOfferCount(); i++) {
		Offer offer = config.getOffer(i);

		// map store-specific identifiers with our default identifier!
		String identifier = offer.getIdentifier();
		Set<Map.Entry<String, String>> identifierForStores = offer.getIdentifierForStores();
		for (Map.Entry<String, String> entry : identifierForStores) {
			String storeNameOpenIAB = storeNameToOpenIAB(entry.getKey());
			if (storeNameOpenIAB != null) {
			    // if the store name is 'null', it doesn't belong to OpenIAB & we ignore (e.g. iOS store!)
   				String identifierForStore = entry.getValue();
   				if (!(SkuManager.getInstance().getStoreSku(storeNameOpenIAB, identifier).equals(identifierForStore))) {
   					SkuManager.getInstance().mapSku(identifier, storeNameOpenIAB, identifierForStore);
   				}
			}
		}
	}
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:22,代码来源:PurchaseManagerAndroidOpenIAB.java

示例3: getPurchaseManagerConfig

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
@Override
protected PurchaseManagerConfig getPurchaseManagerConfig()
{
    PurchaseManagerConfig purchaseManagerConfig = new PurchaseManagerConfig();

    for (LevelPack levelPack : LevelManager.getLevelPacks())
    {
        if (!levelPack.isFree())
        {
            Offer offer = new Offer();
            offer
                .setType(OfferType.ENTITLEMENT)
                .setIdentifier(levelPack.getGoogleSku());
            offer.putIdentifierForStore(
                PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE,
                levelPack.getGoogleSku());
            purchaseManagerConfig.addOffer(offer);
        }
    }

    String key = PhysicsComponent.s(com.draga.shape.Circle.s(
        GraphicComponent.s(Circle.s)
            + MenuScreen.s(IngameMenuScreen.s, -3)
            + GraphicComponent.s(HudScreen.s)
            + MenuScreen.s(DeadZoneInputModifier.s, 4)
            + GraphicComponent.s(Joystick.s)));
    purchaseManagerConfig.addStoreParam(
        PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE,
        key);

    return purchaseManagerConfig;
}
 
开发者ID:overengineering,项目名称:space-travels-3,代码行数:33,代码来源:AndroidServices.java

示例4: purchase

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
@Override
public void purchase(String identifier) {
    // Find the SKProduct for this identifier.
    Offer offer = config.getOffer(identifier);
    if (offer == null) {
        log(LOGTYPEERROR, "Invalid product identifier, " + identifier);
        observer.handlePurchaseError(new RuntimeException("Invalid product identifier, " + identifier));
    } else {
        String identifierForStore = offer.getIdentifierForStore
                (PurchaseManagerConfig.STORE_NAME_IOS_APPLE);
        SKProduct product = getProductByStoreIdentifier(identifierForStore);
        if (product == null) {
            // Product with this identifier not found: load product info first and try to purchase again
            log(LOGTYPELOG, "Requesting product info for " + identifierForStore);
            NSMutableSet<String> identifierForStoreSet = (NSMutableSet<String>) NSMutableSet
                    .alloc().initWithCapacity(1);
            identifierForStoreSet.addObject(identifierForStore);
            productsRequest = SKProductsRequest.alloc().initWithProductIdentifiers
                    (identifierForStoreSet);
            productsRequest.setDelegate(new AppleProductsDelegatePurchase());
            productsRequest.start();
        } else {
            // Create a SKPayment from the product and start purchase flow
            log(LOGTYPELOG, "Purchasing product " + identifier + " ...");
            SKPayment payment = SKPayment.paymentWithProduct(product);
            ((SKPaymentQueue) SKPaymentQueue.defaultQueue()).addPayment(payment);
        }
    }
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:30,代码来源:PurchaseManageriOSApple.java

示例5: getPurchaseIdsByType

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
private void getPurchaseIdsByType(List<String> inAppPurchasesIds, List<String> subsPurchasesIds) {
    for (int i = 0; i < purchaseManagerConfig.getOfferCount(); i++) {
        Offer offer = purchaseManagerConfig.getOffer(i);
        if (offer.getType().equals(OfferType.SUBSCRIPTION))
            subsPurchasesIds.add(offer.getIdentifier());
        else
            inAppPurchasesIds.add(offer.getIdentifier());
    }
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:10,代码来源:AndroidGooglePlayPurchaseManager.java

示例6: getOfferType

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
private OfferType getOfferType(String identifier) {
    Offer offer = purchaseManagerConfig.getOffer(identifier);
    if (offer == null || offer.getType() == null) {
        throw new IllegalStateException("No offer or offerType configured for identifier: " + identifier + ", offer: " + offer);
    }

    return offer.getType();
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:9,代码来源:AndroidGooglePlayPurchaseManager.java

示例7: skuDetailsResponseResultOkProductFullEditionEntitlement

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
public static Bundle skuDetailsResponseResultOkProductFullEditionEntitlement() {
    Offer offer = OfferObjectMother.offerFullEditionEntitlement();
    Information information = InformationObjectMother.informationFullEditionEntitlement();

    Bundle bundle = new Bundle(3);

    bundle.putInt(RESPONSE_CODE, BILLING_RESPONSE_RESULT_OK.getCode());
    bundle.putStringArrayList(ITEM_ID_LIST, itemIdList(offer));
    bundle.putStringArrayList(DETAILS_LIST, bundleDetailList(offer, information));

    return bundle;
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:13,代码来源:GetSkuDetailsResponseBundleObjectMother.java

示例8: skuDetailsResponseResultOkNoPriceAmountMicrosInDetailList

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
public static Bundle skuDetailsResponseResultOkNoPriceAmountMicrosInDetailList() {
    Offer offer = OfferObjectMother.offerFullEditionEntitlement();
    Information information = InformationObjectMother.informationFullEditionEntitlement();

    Bundle bundle = new Bundle(3);

    bundle.putInt(RESPONSE_CODE, BILLING_RESPONSE_RESULT_OK.getCode());
    bundle.putStringArrayList(ITEM_ID_LIST, itemIdList(offer));
    bundle.putStringArrayList(DETAILS_LIST, bundleDetailListNoPriceAmountMicros(offer, information));

    return bundle;
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:13,代码来源:GetSkuDetailsResponseBundleObjectMother.java

示例9: bundleDetailList

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
private static ArrayList<String> bundleDetailList(Offer offer, Information information) {
    JSONObject object = makeJsonObject(offer, information);

    ArrayList<String> list = new ArrayList<>();
    list.add(object.toString());
    return list;
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:8,代码来源:GetSkuDetailsResponseBundleObjectMother.java

示例10: makeJsonObject

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
private static JSONObject makeJsonObject(Offer offer, Information information) {
    JSONObject object = new JSONObject();

    try {
        object.put(GoogleBillingConstants.SKU_TITLE, information.getLocalName());
        object.put(GoogleBillingConstants.SKU_DESCRIPTION, information.getLocalDescription());
        object.put(GoogleBillingConstants.SKU_PRICE, information.getLocalPricing());
        object.put(GoogleBillingConstants.PRODUCT_ID, offer.getIdentifier());
        object.put(GoogleBillingConstants.PRICE_AMOUNT_MICROS, information.getPriceInCents() * 10_000);
        object.put(GoogleBillingConstants.PRICE_CURRENCY_CODE, information.getPriceCurrencyCode());
    } catch(JSONException e) {
        throw new IllegalStateException("Failed to create json object", e);
    }
    return object;
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:16,代码来源:GetSkuDetailsResponseBundleObjectMother.java

示例11: makeInAppPurchaseJsonData

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
private static String makeInAppPurchaseJsonData() {
    Offer offer = offerFullEditionEntitlement();

    try {
        return makeJsonObjectForOffer(offer);
    } catch(JSONException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:10,代码来源:PurchaseRequestActivityResultObjectMother.java

示例12: makeJsonObjectForOffer

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
private static String makeJsonObjectForOffer(Offer offer) throws JSONException {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put(GoogleBillingConstants.PRODUCT_ID, offer.getIdentifier());
    jsonObject.put(GoogleBillingConstants.PURCHASE_TIME, System.currentTimeMillis());
    jsonObject.put(GoogleBillingConstants.ORDER_ID, "GPA.1234-5678-9012-34567");

    return jsonObject.toString();
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:9,代码来源:PurchaseRequestActivityResultObjectMother.java

示例13: connectBindAndForFullEditionEntitlement

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
private void connectBindAndForFullEditionEntitlement() throws android.os.RemoteException {
    Offer offer = offerFullEditionEntitlement();
    Information information = informationFullEditionEntitlement();

    whenGetProductsDetailsReturn(offer.getIdentifier(), information);

    bindFetchNewConnectionAndInstallPurchaseSystem();
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:9,代码来源:AndroidGooglePlayPurchaseManagerTest.java

示例14: convertsConfigWithOneOffer

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
@Test
public void convertsConfigWithOneOffer() throws Exception {
    Offer offer = offerFullEditionEntitlement();

    Bundle bundle = convertProductIdsToItemIdList(singletonList(offer.getIdentifier()));

    assertEquals(1, bundle.size());
    ArrayList<String> actualList = bundle.getStringArrayList(ITEM_ID_LIST);

    ArrayList<String> expectedArrayList = new ArrayList<>(singletonList(offerFullEditionEntitlement().getIdentifier()));
    assertEquals(expectedArrayList, actualList);
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:13,代码来源:GetSkuDetailsRequestConverterTest.java

示例15: getIdsForEntitlementsAndConsumables

import com.badlogic.gdx.pay.Offer; //导入依赖的package包/类
private List<String> getIdsForEntitlementsAndConsumables() {
	final List<String> result = new ArrayList<String>();
	final int offerCount = config.getOfferCount();
	for (int i = 0; i < offerCount; i++) {
		Offer offer = config.getOffer(i);
		if (offer.getType() == OfferType.ENTITLEMENT || offer.getType() == OfferType.CONSUMABLE) {
			result.add(offer.getIdentifier());
		}
	}
	return result;
}
 
开发者ID:libgdx,项目名称:gdx-pay,代码行数:12,代码来源:PurchaseManagerAndroidOpenIAB.java


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