Search in sources :

Example 6 with UnexpectedStoreErrorEvent

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

the class StoreInfo method setStoreAssets.

/**
     * Another option to set the data of StoreInfo. This will usually be used from game engine
     * wrappers like Unity or Cocos2dx.
     *
     * @param version       the version of IStoreAssets.
     * @param storeMetaJSON the store metadata as JSON.
     */
public static void setStoreAssets(int version, String storeMetaJSON) {
    SoomlaUtils.LogDebug(TAG, "trying to set json: " + storeMetaJSON);
    if (TextUtils.isEmpty(storeMetaJSON)) {
        SoomlaUtils.LogError(TAG, "The given store assets JSON can't be empty or null!");
        return;
    }
    mCurrentAssetsVersion = version;
    // loaded - in that case we initialize with setStoreAssets.
    if (!loadFromDB()) {
        SoomlaUtils.LogDebug(TAG, "didn't find anything in DB to load. continuing with store assets json.");
        try {
            fromJSONObject(new JSONObject(storeMetaJSON));
            save();
        } catch (JSONException e) {
            SoomlaUtils.LogError(TAG, "Can't parse store metadata json. That's a major issue." + storeMetaJSON);
            BusProvider.getInstance().post(new UnexpectedStoreErrorEvent(UnexpectedStoreErrorEvent.ErrorCode.GENERAL));
        }
    }
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) UnexpectedStoreErrorEvent(com.soomla.store.events.UnexpectedStoreErrorEvent)

Aggregations

UnexpectedStoreErrorEvent (com.soomla.store.events.UnexpectedStoreErrorEvent)6 PurchasableVirtualItem (com.soomla.store.domain.PurchasableVirtualItem)4 VirtualItemNotFoundException (com.soomla.store.exceptions.VirtualItemNotFoundException)4 IabPurchase (com.soomla.store.billing.IabPurchase)2 IabCallbacks (com.soomla.store.billing.IabCallbacks)1 MarketPurchaseCancelledEvent (com.soomla.store.events.MarketPurchaseCancelledEvent)1 MarketPurchaseStartedEvent (com.soomla.store.events.MarketPurchaseStartedEvent)1 MarketRefundEvent (com.soomla.store.events.MarketRefundEvent)1 VerificationStartedEvent (com.soomla.store.events.VerificationStartedEvent)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1