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:com.appsimobile.appsii.iab.IabInventoryHelper.java

int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null)
        skuList.addAll(moreSkus);//  w  ww .  j  ava 2  s  . c  o  m

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

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    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);

    int N = responseList.size();
    for (int i = 0; i < N; i++) {
        String thisResponse = responseList.get(i);
        SkuDetails d = new SkuDetails(itemType, thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}

From source file:anomalyDetector.activities.MainFeaturesActivity.java

public void startService(View view) {

    Intent intent = new Intent(ColectFeaturesService.COLECT_FEATURE_SERVICE);

    Bundle bundle = new Bundle();
    bundle.putStringArrayList(SELECTED_FEATURES, selectedFeatures);

    intent.putExtras(bundle);/*  w  ww  .j a  v  a 2 s .  c  o  m*/

    startService(intent);
    isServiceRunning = true;
    drawerItemClickListener.setServiceRunning(true);

    startServiceButton = (Button) findViewById(R.id.startServiceButton);
    startServiceButton.setEnabled(false);
    stopServiceButton = (Button) findViewById(R.id.stopServiceButton);
    stopServiceButton.setEnabled(true);
}

From source file:eu.trentorise.smartcampus.eb.fragments.experience.AssignCollectionFragment.java

@Override
public void onSaveInstanceState(Bundle out) {
    super.onSaveInstanceState(out);
    out.putBooleanArray("selected", selected == null ? new boolean[0] : selected);
    out.putStringArrayList("selectedIds",
            selectedIds == null ? new ArrayList<String>() : new ArrayList<String>(selectedIds));
    out.putStringArray("items", items);
}

From source file:org.schabi.newpipe.util.NavStack.java

public void onSaveInstanceState(Bundle state) {
    ArrayList<String> sa = new ArrayList<>();
    for (NavEntry entry : stack) {
        sa.add(entry.url);/* w ww. j a v a 2s  .  c o  m*/
    }
    state.putStringArrayList(NAV_STACK, sa);
}

From source file:com.skubit.android.example.MainActivity.java

public void fetchSkus(final ListView view) {
    Thread t = new Thread(new Runnable() {

        @Override/*  ww w.j  av  a2 s . c  o m*/
        public void run() {
            ArrayList<String> ids = new ArrayList<String>();
            ///ids.add("445");
            //ids.add("440");
            ids.add("contribA");
            final Bundle skusBundle = new Bundle();
            skusBundle.putStringArrayList("ITEM_ID_LIST", ids);

            try {
                Bundle skuDetails = mService.getSkuDetails(1, getApplicationContext().getPackageName(),
                        "donation", skusBundle);

                final ArrayList<String> details = skuDetails.getStringArrayList("DETAILS_LIST");
                final SkusFragment skusFragment = (SkusFragment) mAdapter.getItem(0);

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            skusFragment.displaySkus(MainActivity.this, view, details);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                });

            } catch (Exception e) {
                e.printStackTrace();
            }

        }

    });
    t.start();

}

From source file:org.strongswan.android.ui.SelectedApplicationsListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putStringArrayList(VpnProfileDataSource.KEY_SELECTED_APPS_LIST, new ArrayList<>(mSelection));
}

From source file:com.commonsware.android.ab.search.ActionBarFragment.java

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

    if (!sv.isIconified()) {
        state.putCharSequence(STATE_QUERY, sv.getQuery());
    }/*from ww  w  .  ja  va  2 s  .  c  o m*/

    state.putStringArrayList(STATE_MODEL, words);
}

From source file:org.solovyev.android.checkout.GetPurchasesRequestTest.java

@Test
public void testShouldErrorIfJsonException() throws Exception {
    final GetPurchasesRequest request = newRequest();
    final RequestListener l = mock(RequestListener.class);
    request.setListener(l);/*from w w w . j  a  va  2s.  c o m*/
    final IInAppBillingService service = mock(IInAppBillingService.class);
    final Bundle bundle = newBundle(OK);
    final ArrayList<String> datas = new ArrayList<String>();
    datas.add("test");
    bundle.putStringArrayList(Purchases.BUNDLE_DATA_LIST, datas);
    when(service.getPurchases(anyInt(), anyString(), anyString(), anyString())).thenReturn(bundle);

    request.start(service, 3, "test");

    verify(l, times(1)).onError(eq(EXCEPTION), any(JSONException.class));
}

From source file:com.google.sample.castcompanionlibrary.utils.Utils.java

/**
 * Builds and returns a {@link Bundle} which contains a select subset of data in the
 * {@link MediaInfo}. Since {@link MediaInfo} is not {@link Parcelable}, one can use this
 * container bundle to pass around from one activity to another.
 *
 * @param info/*from   www . j  a v  a 2  s  .  co  m*/
 * @return
 * @see <code>toMediaInfo()</code>
 */
public static Bundle fromMediaInfo(MediaInfo info) {
    if (null == info) {
        return null;
    }

    MediaMetadata md = info.getMetadata();
    Bundle wrapper = new Bundle();
    wrapper.putString(MediaMetadata.KEY_TITLE, md.getString(MediaMetadata.KEY_TITLE));
    wrapper.putString(MediaMetadata.KEY_SUBTITLE, md.getString(MediaMetadata.KEY_SUBTITLE));
    wrapper.putString(KEY_URL, info.getContentId());
    wrapper.putString(MediaMetadata.KEY_STUDIO, md.getString(MediaMetadata.KEY_STUDIO));
    wrapper.putString(KEY_CONTENT_TYPE, info.getContentType());
    wrapper.putInt(KEY_STREAM_TYPE, info.getStreamType());
    wrapper.putLong(KEY_STREAM_DURATION, info.getStreamDuration());
    if (!md.getImages().isEmpty()) {
        ArrayList<String> urls = new ArrayList<String>();
        for (WebImage img : md.getImages()) {
            urls.add(img.getUrl().toString());
        }
        wrapper.putStringArrayList(KEY_IMAGES, urls);
    }
    JSONObject customData = info.getCustomData();
    if (null != customData) {
        wrapper.putString(KEY_CUSTOM_DATA, customData.toString());
    }
    if (info.getMediaTracks() != null && !info.getMediaTracks().isEmpty()) {
        try {
            JSONArray jsonArray = new JSONArray();
            for (MediaTrack mt : info.getMediaTracks()) {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put(KEY_TRACK_NAME, mt.getName());
                jsonObject.put(KEY_TRACK_CONTENT_ID, mt.getContentId());
                jsonObject.put(KEY_TRACK_ID, mt.getId());
                jsonObject.put(KEY_TRACK_LANGUAGE, mt.getLanguage());
                jsonObject.put(KEY_TRACK_TYPE, mt.getType());
                jsonObject.put(KEY_TRACK_SUBTYPE, mt.getSubtype());
                if (null != mt.getCustomData()) {
                    jsonObject.put(KEY_TRACK_CUSTOM_DATA, mt.getCustomData().toString());
                }
                jsonArray.put(jsonObject);
            }
            wrapper.putString(KEY_TRACKS_DATA, jsonArray.toString());
        } catch (JSONException e) {
            LOGE(TAG, "fromMediaInfo(): Failed to convert Tracks data to json", e);
        }
    }

    return wrapper;
}

From source file:com.brucetoo.imagebrowse.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    imgList.add(0, "http://cdn.at.cn/upload/146336617940.jpg");
    imgList.add(1, "http://cdn.at.cn/upload/146540079128.jpg");
    imgList.add(2, "http://cdn.at.cn/upload/146528287960.jpg");
    imgList.add(3, "http://cdn.at.cn/upload/146271377052.jpg");
    imgList.add(4, "http://cdn.at.cn/upload/146502027460.jpg");
    imgList.add(5, "http://cdn.at.cn/upload/146296005117.jpg");
    imgList.add(6, "http://cdn.at.cn/upload/146386101517.jpg");
    imgList.add(7, "http://cdn.at.cn/upload/146289180072.jpg");
    imgList.add(8, "http://cdn.at.cn/upload/146378563799.jpg");
    //        imgList.add(0, "http://img6.cache.netease.com/3g/2015/9/30/20150930091938133ad.jpg");
    //        imgList.add(1, "http://img2.cache.netease.com/3g/2015/9/30/2015093000515435aff.jpg");
    //        imgList.add(2, "http://img5.cache.netease.com/3g/2015/9/30/20150930075225737e5.jpg");
    //        imgList.add(3, "http://img5.cache.netease.com/3g/2015/9/29/20150929213007cd8cd.jpg");
    //        imgList.add(4, "http://img3.cache.netease.com/3g/2015/9/29/20150929162747a8bfa.jpg");
    //        imgList.add(5, "http://img2.cache.netease.com/3g/2015/9/30/20150930091208cf03c.jpg");
    //        imgList.add(6, "http://img2.cache.netease.com/3g/2015/9/30/2015093000515435aff.jpg");
    //        imgList.add(7, "http://img5.cache.netease.com/3g/2015/9/29/20150929213007cd8cd.jpg");
    //        imgList.add(8, "http://img3.cache.netease.com/3g/2015/9/29/20150929162747a8bfa.jpg");
    gridView = (GridView) findViewById(R.id.gridview);
    root = findViewById(R.id.layout_root);
    final ImageAdapter adapter = new ImageAdapter();
    gridView.setAdapter(adapter);//from   w  w  w.j  a  v  a2s  .c  o  m

    gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> parent, final View view, final int position, long id) {
            if (view.isEnabled()) {
                //Use of ImageBrowseFragment
                Bundle bundle = new Bundle();
                bundle.putStringArrayList(ImageInfo.INTENT_IMAGE_URLS, imgList);
                bundle.putParcelable(ImageInfo.INTENT_CLICK_IMAGE_INFO, ((PhotoView) view).getInfo());
                bundle.putInt(ImageInfo.INTENT_CLICK_IMAGE_POSITION, position);
                imgImageInfos.clear();
                //NOTE:if imgList.size >= the visible count in single screen,i will cause NullPointException
                //because item out of screen have been replaced/reused
                for (int i = 0; i < imgList.size(); i++) {
                    imgImageInfos.add(((PhotoView) parent.getChildAt(i)).getInfo());
                }
                parent.getChildAt(position);
                bundle.putParcelableArrayList(ImageInfo.INTENT_IMAGE_INFOS, imgImageInfos);
                getSupportFragmentManager()
                        .beginTransaction().replace(Window.ID_ANDROID_CONTENT,
                                ImageBrowseFragment.newInstance(bundle), "ViewPagerFragment")
                        .addToBackStack(null).commit();

                //Use of ImageBrowseDialogFragment
                //                    root.post(new Runnable() { // in case root view not inflate complete
                //                        @Override
                //                        public void run() {
                //                            Bundle bundle = new Bundle();
                //                            bundle.putStringArrayList(ImageInfo.INTENT_IMAGE_URLS, imgList);
                //                            final ImageInfo preImgInfo = ((PhotoView) view).getInfo();
                //                            bundle.putParcelable(ImageInfo.INTENT_CLICK_IMAGE_INFO, preImgInfo);
                //                            bundle.putInt(ImageInfo.INTENT_CLICK_IMAGE_POSITION, position);
                //                            imgImageInfos.clear();
                //                            for (int i = 0; i < imgList.size(); i++) {
                //                                imgImageInfos.add(((PhotoView) parent.getChildAt(i)).getInfo());
                //                            }
                //                            bundle.putParcelableArrayList(ImageInfo.INTENT_IMAGE_INFOS, imgImageInfos);
                //                            int[] position = new int[2];
                //                            root.getLocationOnScreen(position);
                //                            //Must correct the ImageInfo in DialogFragment
                //                            preImgInfo.correct(position, getStatusBarHeight());
                //                            for (ImageInfo item : imgImageInfos) {
                //                                item.correct(position,getStatusBarHeight());
                //                            }
                //                            ImageBrowseDialogFragment.newInstance(bundle).show(getSupportFragmentManager(), ImageBrowseDialogFragment.class.getSimpleName());
                //                        }
                //                    });
            }
        }
    });
}