Example usage for android.os Bundle putStringArrayList

List of usage examples for android.os Bundle putStringArrayList

Introduction

In this page you can find the example usage for android.os Bundle putStringArrayList.

Prototype

@Override
public void putStringArrayList(@Nullable String key, @Nullable ArrayList<String> value) 

Source Link

Document

Inserts an ArrayList value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:org.inaturalist.android.GuideDetails.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putSerializable("guide", mGuide);
    outState.putString("guideXmlFilename", mGuideXmlFilename);
    outState.putString("filterSearchText", mFilter.getSearchText());
    outState.putStringArrayList("filterTags", (ArrayList<String>) mFilter.getAllTags());
    outState.putBoolean("isDownloading", mIsDownloading);
    outState.putInt("downloadProgress", mDownloadProgress);
    super.onSaveInstanceState(outState);
}

From source file:org.dmfs.webcal.utils.billing.IabHelper.java

int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");

    Context context = mContext;/*  w  w w  .  j  ava 2s  .c  om*/
    IInAppBillingService service = mService;
    if (context == null || service == null) {
        return IABHELPER_BAD_RESPONSE;
    }

    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            if (!skuList.contains(sku)) {
                skuList.add(sku);
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    while (skuList.size() > 0) {
        ArrayList<String> skuSubList = new ArrayList<String>(skuList.subList(0, Math.min(19, skuList.size())));
        skuList.removeAll(skuSubList);

        Bundle querySkus = new Bundle();
        querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuSubList);
        Bundle skuDetails = service.getSkuDetails(3, context.getPackageName(), itemType, querySkus);

        if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
            int response = getResponseCodeFromBundle(skuDetails);
            if (response != BILLING_RESPONSE_RESULT_OK) {
                logDebug("getSkuDetails() failed: " + getResponseDesc(response));
                return response;
            } else {
                logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
                return IABHELPER_BAD_RESPONSE;
            }
        }

        ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

        for (String thisResponse : responseList) {
            SkuDetails d = new SkuDetails(itemType, thisResponse);
            logDebug("Got sku details: " + d);
            inv.addSkuDetails(d);
        }
    }
    return BILLING_RESPONSE_RESULT_OK;
}

From source file:plugin.google.iap.v3.util.IabHelper.java

int querySkuDetails(String itemType, Inventory inv, Set<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        Iterator<String> iterator = moreSkus.iterator();
        while (iterator.hasNext()) {
            String sku = iterator.next();
            if (!skuList.contains(sku)) {
                skuList.add(sku);//from  ww w .  j  a v  a  2s .c o  m
            }
        }
    }

    if (mService == null) {
        return BILLING_RESPONSE_RESULT_ERROR;
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    ArrayList<ArrayList<String>> packets = new ArrayList<ArrayList<String>>();
    ArrayList<String> packet = new ArrayList<String>();
    while (skuList.size() > 0) {
        if (packet.size() > 19) {
            packets.add(packet);
            packet = new ArrayList<String>();
        }

        packet.add(skuList.remove(0));
    }
    packets.add(packet);

    for (ArrayList<String> aSkuList : packets) {
        Bundle querySkus = new Bundle();
        querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, aSkuList);
        Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus);

        if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
            int response = getResponseCodeFromBundle(skuDetails);
            if (response != BILLING_RESPONSE_RESULT_OK) {
                logDebug("getSkuDetails() failed: " + getResponseDesc(response));
                return response;
            } else {
                logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
                return IABHELPER_BAD_RESPONSE;
            }
        }

        ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

        for (String thisResponse : responseList) {
            SkuDetails d = new SkuDetails(itemType, thisResponse);
            logDebug("Got sku details: " + d);
            inv.addSkuDetails(d);
        }
    }

    return BILLING_RESPONSE_RESULT_OK;
}

From source file:io.github.hidroh.materialistic.widget.StoryRecyclerViewAdapter.java

@Override
public Bundle saveState() {
    Bundle savedState = super.saveState();
    savedState.putParcelableArrayList(STATE_ITEMS, mItems);
    savedState.putParcelableArrayList(STATE_UPDATED, mUpdated);
    ArrayList<String> promotedKey = new ArrayList<>(mPromoted.size());
    ArrayList<Integer> promotedValue = new ArrayList<>(mPromoted.size());
    for (Map.Entry<String, Integer> entry : mPromoted.entrySet()) {
        promotedKey.add(entry.getKey());
        promotedValue.add(entry.getValue());
    }/*from   w ww.j a  v a2 s . co  m*/
    savedState.putStringArrayList(STATE_PROMOTED_KEY, promotedKey);
    savedState.putIntegerArrayList(STATE_PROMOTED_VALUE, promotedValue);
    savedState.putBoolean(STATE_SHOW_ALL, mShowAll);
    savedState.putBoolean(STATE_HIGHLIGHT_UPDATED, mHighlightUpdated);
    savedState.putInt(STATE_FAVORITE_REVISION, mFavoriteRevision);
    savedState.putString(STATE_USERNAME, mUsername);
    return savedState;
}

From source file:com.money.manager.ex.account.AccountTransactionListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    if (mAccountId != null) {
        outState.putInt(KEY_CONTENT, mAccountId);
    }/*from  w  ww  .j  a v a 2 s.co m*/

    outState.putStringArrayList(KEY_STATUS, mFilter.transactionStatus.filter);
}

From source file:com.andersson.minesweeper.util.IabHelper.java

private int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            if (!skuList.contains(sku)) {
                skuList.add(sku);// w  w w  .ja  va  2 s  .  c  om
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    // Split the sku list in blocks of no more than 20 elements.
    ArrayList<ArrayList<String>> packs = new ArrayList<ArrayList<String>>();
    ArrayList<String> tempList;
    int n = skuList.size() / 20;
    int mod = skuList.size() % 20;
    for (int i = 0; i < n; i++) {
        tempList = new ArrayList<String>();
        for (String s : skuList.subList(i * 20, i * 20 + 20)) {
            tempList.add(s);
        }
        packs.add(tempList);
    }
    if (mod != 0) {
        tempList = new ArrayList<String>();
        for (String s : skuList.subList(n * 20, n * 20 + mod)) {
            tempList.add(s);
        }
        packs.add(tempList);
    }

    for (ArrayList<String> skuPartList : packs) {
        Bundle querySkus = new Bundle();
        querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuPartList);
        Bundle skuDetails = mService.getSkuDetails(3, mPackageName, itemType, querySkus);

        if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
            int response = getResponseCodeFromBundle(skuDetails);
            if (response != BILLING_RESPONSE_RESULT_OK) {
                logDebug("getSkuDetails() failed: " + getResponseDesc(response));
                return response;
            } else {
                logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
                return IABHELPER_BAD_RESPONSE;
            }
        }

        ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

        for (String thisResponse : responseList) {
            SkuDetails d = new SkuDetails(itemType, thisResponse);
            logDebug("Got sku details: " + d);
            inv.addSkuDetails(d);
        }
    }

    return BILLING_RESPONSE_RESULT_OK;
}

From source file:org.onepf.oms.appstore.skubitUtils.SkubitIabHelper.java

/**
 * @param inv      - Inventory with application SKUs
 * @param moreSkus - storeSKUs (processed in {@link OpenIabHelper#queryInventory(boolean, List, List)}
 *///from  w ww. j  a v  a 2 s. co m
int querySkuDetails(String itemType, @NotNull Inventory inv, @Nullable List<String> moreSkus)
        throws RemoteException, JSONException {
    Logger.d("querySkuDetails() Querying SKU details.");
    final SkuManager skuManager = SkuManager.getInstance();
    final String appstoreName = mAppstore.getAppstoreName();

    Set<String> storeSkus = new TreeSet<String>();
    for (String sku : inv.getAllOwnedSkus(itemType)) {
        storeSkus.add(skuManager.getStoreSku(appstoreName, sku));
    }
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            storeSkus.add(skuManager.getStoreSku(appstoreName, sku));
        }
    }
    if (storeSkus.isEmpty()) {
        Logger.d("querySkuDetails(): nothing to do because there are no SKUs.");
        return RESULT_OK;
    }

    // Split the sku list in blocks of no more than QUERY_SKU_DETAILS_BATCH_SIZE elements.
    ArrayList<ArrayList<String>> batches = new ArrayList<ArrayList<String>>();
    ArrayList<String> tmpBatch = new ArrayList<String>(QUERY_SKU_DETAILS_BATCH_SIZE);
    int iSku = 0;
    for (String sku : storeSkus) {
        tmpBatch.add(sku);
        iSku++;
        if (tmpBatch.size() == QUERY_SKU_DETAILS_BATCH_SIZE || iSku == storeSkus.size()) {
            batches.add(tmpBatch);
            tmpBatch = new ArrayList<String>(QUERY_SKU_DETAILS_BATCH_SIZE);
        }
    }

    Logger.d("querySkuDetails() batches: ", batches.size(), ", ", batches);

    for (ArrayList<String> batch : batches) {
        Bundle querySkus = new Bundle();
        querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, batch);
        if (mService == null) {
            Logger.e("In-app billing error: unable to get sku details: service is not connected.");
            return IABHELPER_BAD_RESPONSE;
        }
        Bundle skuDetails = mService.getSkuDetails(1, mContext.getPackageName(), itemType, querySkus);

        if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
            int response = getResponseCodeFromBundle(skuDetails);
            if (response != RESULT_OK) {
                Logger.d("getSkuDetails() failed: ", getResponseDesc(response));
                return response;
            } else {
                Logger.e(
                        "In-app billing error: getSkuDetails() returned a bundle with neither an error nor a detail list.");
                return IABHELPER_BAD_RESPONSE;
            }
        }

        ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

        for (String thisResponse : responseList) {
            SkuDetails d = new SkuDetails(itemType, thisResponse);
            d.setSku(SkuManager.getInstance().getSku(appstoreName, d.getSku()));
            Logger.d("querySkuDetails() Got sku details: ", d);
            inv.addSkuDetails(d);
        }
    }

    return RESULT_OK;
}

From source file:com.smartmobilesoftware.util.IabHelper.java

int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        logDebug("moreSkus: Building SKUs List");
        for (String sku : moreSkus) {
            logDebug("moreSkus: " + sku);
            if (!skuList.contains(sku)) {
                skuList.add(sku);/*from ww w .jav  a 2s  . c  o  m*/
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    // Split the SKUs into slices of maximum 20 entries before querying them to prevent 
    // "Input Error: skusBundle array associated with key ITEM_ID_LIST cannot contain more than 20 items."
    while (skuList.size() > 0) {
        ArrayList<String> skuSubList = new ArrayList<String>(skuList.subList(0, Math.min(19, skuList.size())));
        skuList.removeAll(skuSubList);

        Bundle querySkus = new Bundle();
        querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuSubList);
        Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus);

        if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
            int response = getResponseCodeFromBundle(skuDetails);
            if (response != BILLING_RESPONSE_RESULT_OK) {
                logDebug("getSkuDetails() failed: " + getResponseDesc(response));
                return response;
            } else {
                logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
                return ERR_BAD_RESPONSE;
            }
        }

        ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

        for (String thisResponse : responseList) {
            SkuDetails d = new SkuDetails(itemType, thisResponse);
            logDebug("Got sku details: " + d);
            inv.addSkuDetails(d);
        }
    }
    return BILLING_RESPONSE_RESULT_OK;
}

From source file:com.facebook.android.friendsmash.HomeActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    // Save the logged-in state
    outState.putBoolean(FriendSmashApplication.getLoggedInKey(),
            ((FriendSmashApplication) getApplication()).isLoggedIn());

    // Save the currentFBUser
    if (((FriendSmashApplication) getApplication()).getCurrentFBUser() != null) {
        outState.putString(FriendSmashApplication.getCurrentFbUserKey(),
                ((FriendSmashApplication) getApplication()).getCurrentFBUser().getInnerJSONObject().toString());
    }//from   www  . j  a v a 2s. c o  m

    // Save the logged-in user's list of friends
    if (((FriendSmashApplication) getApplication()).getFriends() != null) {
        outState.putStringArrayList(FriendSmashApplication.getFriendsKey(),
                ((FriendSmashApplication) getApplication()).getFriendsAsArrayListOfStrings());
    }
}

From source file:com.ffmpeger.card.iabutils.IabHelper.java

int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            if (!skuList.contains(sku)) {
                skuList.add(sku);//from   w w w  .j ava2  s  .c  o  m
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    // Split the sku list in blocks of no more than 20 elements.
    ArrayList<ArrayList<String>> packs = new ArrayList<ArrayList<String>>();
    ArrayList<String> tempList;
    int n = skuList.size() / 20;
    int mod = skuList.size() % 20;
    for (int i = 0; i < n; i++) {
        tempList = new ArrayList<String>();
        for (String s : skuList.subList(i * 20, i * 20 + 20)) {
            tempList.add(s);
        }
        packs.add(tempList);
    }
    if (mod != 0) {
        tempList = new ArrayList<String>();
        for (String s : skuList.subList(n * 20, n * 20 + mod)) {
            tempList.add(s);
        }
        packs.add(tempList);

        for (ArrayList<String> skuPartList : packs) {
            Bundle querySkus = new Bundle();
            querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuPartList);
            Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus);

            if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
                int response = getResponseCodeFromBundle(skuDetails);
                if (response != BILLING_RESPONSE_RESULT_OK) {
                    logDebug("getSkuDetails() failed: " + getResponseDesc(response));
                    return response;
                } else {
                    logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
                    return IABHELPER_BAD_RESPONSE;
                }
            }

            ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

            for (String thisResponse : responseList) {
                SkuDetails d = new SkuDetails(itemType, thisResponse);
                logDebug("Got sku details: " + d);
                inv.addSkuDetails(d);
            }
        }

    }

    return BILLING_RESPONSE_RESULT_OK;
}