Search in sources :

Example 11 with UpgradeVG

use of com.soomla.store.domain.virtualGoods.UpgradeVG in project android-store by soomla.

the class VirtualGoodsStorage method assignCurrentUpgrade.

/**
     * Assigns a specific upgrade to the given virtual good.
     *
     * @param goodItemId the VirtualGood to upgrade
     * @param upgradeVGItemId the upgrade to assign
     * @param notify if true post event to bus
     */
public void assignCurrentUpgrade(String goodItemId, String upgradeVGItemId, boolean notify) {
    String upgradeItemId = getCurrentUpgrade(goodItemId);
    if (!TextUtils.isEmpty(upgradeItemId)) {
        try {
            UpgradeVG upgrade = (UpgradeVG) StoreInfo.getVirtualItem(upgradeItemId);
            if (upgrade != null && upgrade.getItemId().equals(upgradeVGItemId)) {
                return;
            }
        } catch (VirtualItemNotFoundException ignored) {
        }
    }
    SoomlaUtils.LogDebug(mTag, "Assigning upgrade " + upgradeVGItemId + " to virtual good: " + goodItemId);
    String key = keyGoodUpgrade(goodItemId);
    KeyValueStorage.setValue(key, upgradeVGItemId);
    if (notify) {
        BusProvider.getInstance().post(new GoodUpgradeEvent(goodItemId, upgradeVGItemId));
    }
}
Also used : UpgradeVG(com.soomla.store.domain.virtualGoods.UpgradeVG) VirtualItemNotFoundException(com.soomla.store.exceptions.VirtualItemNotFoundException) GoodUpgradeEvent(com.soomla.store.events.GoodUpgradeEvent)

Aggregations

UpgradeVG (com.soomla.store.domain.virtualGoods.UpgradeVG)11 VirtualGood (com.soomla.store.domain.virtualGoods.VirtualGood)8 VirtualItemNotFoundException (com.soomla.store.exceptions.VirtualItemNotFoundException)5 VirtualCurrency (com.soomla.store.domain.virtualCurrencies.VirtualCurrency)4 VirtualCurrencyPack (com.soomla.store.domain.virtualCurrencies.VirtualCurrencyPack)4 PurchasableVirtualItem (com.soomla.store.domain.PurchasableVirtualItem)3 VirtualCategory (com.soomla.store.domain.VirtualCategory)3 VirtualItem (com.soomla.store.domain.VirtualItem)3 EquippableVG (com.soomla.store.domain.virtualGoods.EquippableVG)3 PurchaseType (com.soomla.store.purchaseTypes.PurchaseType)3 PurchaseWithMarket (com.soomla.store.purchaseTypes.PurchaseWithMarket)3 LifetimeVG (com.soomla.store.domain.virtualGoods.LifetimeVG)2 SingleUsePackVG (com.soomla.store.domain.virtualGoods.SingleUsePackVG)2 SingleUseVG (com.soomla.store.domain.virtualGoods.SingleUseVG)2 PurchaseWithVirtualItem (com.soomla.store.purchaseTypes.PurchaseWithVirtualItem)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2