Search in sources :

Example 1 with GoodUpgradeEvent

use of com.soomla.store.events.GoodUpgradeEvent in project android-store by soomla.

the class VirtualGoodsStorage method removeUpgrades.

/**
     * Removes any upgrade associated with the given VirtualGood.
     *
     * @param goodItemId the virtual good to remove the upgrade from
     * @param notify if true post event to bus
     */
public void removeUpgrades(String goodItemId, boolean notify) {
    SoomlaUtils.LogDebug(mTag, "Removing upgrade information from virtual good: " + goodItemId);
    String key = keyGoodUpgrade(goodItemId);
    KeyValueStorage.deleteKeyValue(key);
    if (notify) {
        BusProvider.getInstance().post(new GoodUpgradeEvent(goodItemId, null));
    }
}
Also used : GoodUpgradeEvent(com.soomla.store.events.GoodUpgradeEvent)

Example 2 with GoodUpgradeEvent

use of com.soomla.store.events.GoodUpgradeEvent 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

GoodUpgradeEvent (com.soomla.store.events.GoodUpgradeEvent)2 UpgradeVG (com.soomla.store.domain.virtualGoods.UpgradeVG)1 VirtualItemNotFoundException (com.soomla.store.exceptions.VirtualItemNotFoundException)1