Example usage for android.os Bundle putParcelableArrayList

List of usage examples for android.os Bundle putParcelableArrayList

Introduction

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

Prototype

public void putParcelableArrayList(@Nullable String key, @Nullable ArrayList<? extends Parcelable> value) 

Source Link

Document

Inserts a List of Parcelable values into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.bangz.smartmute.LocationsMapFragment.java

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

    if (mSavedMarkerExInfos.isEmpty() == false) {
        mSavedMarkerExInfos.clear();/* w  ww  . j ava2s. c o  m*/
    }

    Collection<Marker> newplaces = markerManager.getCollection(MC_ID_NEWPLACE).getMarkers();

    for (Marker marker : newplaces) {
        mSavedMarkerExInfos.add(markerManager.getExtraInfo(marker));
    }
    Collection<Marker> currplace = markerManager.getCollection(MC_ID_CURRPLACE).getMarkers();
    for (Marker marker : currplace) {
        mSavedMarkerExInfos.add(markerManager.getExtraInfo(marker));
    }

    Bundle mybundle = new Bundle();
    mybundle.putParcelableArrayList(KEY_STATE_MARKERS, mSavedMarkerExInfos);
    mybundle.putInt(KEY_STATE_MAPINIT, mapInitState);
    mybundle.putBoolean(KEY_STATE_LOCATION_UPDATED, bLocationUpdated);
    mybundle.putInt(KEY_STATE_LOCATION_UPDATE_TYPE, mLocationUpdateType);

    if (markerSelected != null) {
        MarkerExInfo meiselected = markerManager.getExtraInfo(markerSelected);
        mybundle.putParcelable(KEY_STATE_SELECT_MARKER, meiselected);
    }

    outState.putBundle(KEY_STATE_MYARGUMENT, mybundle);

}

From source file:com.dycode.jepretstory.mediachooser.activity.HomeFragmentActivity.java

private VideoFragment getVideoFragment() {
    if (mVideoFragment != null) {
        return mVideoFragment;
    }/*  ww w .  j a  v a2s . c  o m*/

    boolean isFromBucket = (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false)));

    mVideoFragment = new VideoFragment();
    Bundle bundle = new Bundle();
    if (isFromBucket) {
        bundle.putString("name", getIntent().getStringExtra("name"));
    }
    if (mCurrentSelectedVideos != null) {
        bundle.putParcelableArrayList("selectedVideos", mCurrentSelectedVideos);
    }
    mVideoFragment.setArguments(bundle);
    return mVideoFragment;
}

From source file:com.baruckis.nanodegree.spotifystreamer.fragments.ArtistsListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {

    // Check if error message is shown and save state if it is.
    if (mInfoView != null && mInfoView.getIsError()) {
        outState.putBoolean(InfoView.STATE_IS_ERROR, mInfoView.getIsError());

        // If artists list is empty or filled with data than save it.
        // If it is null, means initial search message for user is shown.
    } else if (mArtistsList != null) {
        // Serialize and persist found artists list.
        outState.putParcelableArrayList(STATE_ARTISTS_LIST, mArtistsList);
    }//w  ww .  j  a v a2s  .c om

    super.onSaveInstanceState(outState);
}

From source file:org.immopoly.android.api.IS24ApiService.java

@Override
protected void onHandleIntent(Intent intent) {
    final ResultReceiver receiver = intent.getParcelableExtra(API_RECEIVER);
    double lat = intent.getDoubleExtra(LAT, 0.0);
    double lon = intent.getDoubleExtra(LNG, 0.0);
    Bundle b = new Bundle();
    Log.d(Const.LOG_TAG, "IS24 search started");
    try {/*from  w w w. j a  v  a  2s .c o  m*/
        receiver.send(STATUS_RUNNING, Bundle.EMPTY);
        final float[] radii = Const.SEARCH_RADII;
        // search for flats in radii[i]. finish if enough flats found (1 is enough in the last run)
        for (int i = 0; i < radii.length; i++) {
            int min = i == radii.length - 1 ? 1 : Const.SEARCH_MIN_RESULTS;
            Flats flats = loadFlats(lat, lon, radii[i], min, Const.SEARCH_MAX_RESULTS);
            if (flats != null) {
                Log.d(Const.LOG_TAG, "IS24 search finished. #flats: " + flats.size());
                b.putParcelableArrayList("flats", flats);
                receiver.send(STATUS_FINISHED, b);
                this.stopSelf();
                return;
            }
        }
        // no flats found
        Log.d(Const.LOG_TAG, "IS24 search finished with no flats: ");
        b.putString(Intent.EXTRA_TEXT, NO_FLATS);
    } catch (Exception e) {
        Log.e(Const.LOG_TAG, "IS24 search caught Exception: ", e);
    }
    receiver.send(STATUS_ERROR, b);
    this.stopSelf();
}

From source file:com.bitants.wally.fragments.SearchFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    if (imagesAdapter != null) {
        outState.putParcelableArrayList(STATE_IMAGES, imagesAdapter.getImages());
        outState.putString(STATE_QUERY, query);
        outState.putString(STATE_COLOR, currentColor);
        outState.putInt(STATE_COLOR_TEXT, colorTagTextView.getCurrentTextColor());
        outState.putInt(STATE_CURRENT_PAGE, currentPage);
    }/*from  www. jav  a 2 s .c  o  m*/
    super.onSaveInstanceState(outState);
}

From source file:com.gbozza.android.stockhawk.ui.StockFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Cursor stockCursor = mAdapter.getCursor();

    if (null != stockCursor && stockCursor.getCount() != 0) {
        stockCursor.moveToFirst();//from  w  w w. j a  v  a2  s . com
        List<StockParcelable> stockList = new ArrayList<>();
        try {
            do {
                stockList.add(createStockFromCursor(stockCursor));
            } while (stockCursor.moveToNext());
        } catch (Exception e) {
            Timber.e("Cursor Exception");
        }
        outState.putParcelableArrayList(BUNDLE_STOCK_KEY, new ArrayList<>(stockList));
    }
}

From source file:org.xbmc.kore.ui.MediaFileListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putString(MEDIA_TYPE, mediaType);
    try {//from  w w w . j  av a 2  s . c o  m
        outState.putParcelableArrayList(PATH_CONTENTS, (ArrayList<FileLocation>) adapter.getFileItemList());
    } catch (NullPointerException npe) {
        // adapter is null probably nothing was save in bundle because the directory is empty
        // ignore this so that the empty message would display later on
    }
    outState.putParcelableArrayList(ROOT_PATH_CONTENTS, rootFileLocation);
    outState.putBoolean(ROOT_VISITED, browseRootAlready);
}

From source file:com.google.android.apps.flexbox.MainActivity.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    ArrayList<FlexItem> flexItems = new ArrayList<>();
    for (int i = 0; i < mFlexboxLayout.getChildCount(); i++) {
        View child = mFlexboxLayout.getChildAt(i);
        FlexItem flexItem = FlexItem.fromFlexView(child, i);
        flexItems.add(flexItem);/*from   w  w  w  .ja v  a2  s .c o  m*/
    }
    outState.putParcelableArrayList(FLEX_ITEMS_KEY, flexItems);
}

From source file:layout.FragmentBoardItemList.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelableArrayList(SAVED_BOARDITEMS, boardItems);
    outState.putBoolean(RECENT_POST_MODE, recentPostMode);
    outState.putParcelable(ARG_CURRENT_THREAD, currentThread);
    outState.putParcelable(ARG_CURRENTBOARD, currentBoard);
}

From source file:com.bmd.android.collection.SimpleArrayMapTest.java

public void testParcelable() {

    final ParcelableObjectSparseObjectEntry[] parcelableArray = AndroidCollections.iterate(mArray).only()
            .values("4", "1").toParcelableArray(ParcelableObjectSparseObjectEntry.class);

    assertThat(parcelableArray).hasSize(2);
    assertThat(parcelableArray[0].getKey()).isEqualTo(1);
    assertThat(parcelableArray[0].getValue()).isEqualTo("1");
    assertThat(parcelableArray[1].getKey()).isEqualTo(4);
    assertThat(parcelableArray[1].getValue()).isEqualTo("4");

    final ArrayList<ParcelableObjectSparseObjectEntry<Integer, String>> parcelableList = AndroidCollections
            .iterate(mArray).but().keys(Arrays.asList(1, 2, 3)).reverse().toParcelableList();

    assertThat(parcelableList).hasSize(2);
    assertThat(parcelableList.get(0).getKey()).isEqualTo(4);
    assertThat(parcelableList.get(0).getValue()).isEqualTo("4");
    assertThat(parcelableList.get(1).getKey()).isEqualTo(0);
    assertThat(parcelableList.get(1).getValue()).isEqualTo("0");
    assertThat(parcelableList).containsExactly(SparseEntries.parcelableEntry(Integer.valueOf(4), "4"),
            SparseEntries.parcelableEntry(Integer.valueOf(0), "0"));

    final Bundle bundle = new Bundle();
    bundle.putParcelableArray("array", parcelableArray);
    bundle.putParcelableArrayList("list", parcelableList);

    final Parcel parcel = Parcel.obtain();
    bundle.writeToParcel(parcel, 0);//from   w  ww  . j  a  va2  s  .  c  om

    parcel.setDataPosition(0);

    final Bundle out = parcel.readBundle();
    out.setClassLoader(AndroidCollections.class.getClassLoader());

    assertThat(out.getParcelableArray("array")).isEqualTo(parcelableArray);
    assertThat(out.getParcelableArrayList("list")).isEqualTo(new ArrayList<Parcelable>(parcelableList));

    final ArrayList<ParcelableObjectSparseObjectEntry<Integer, String>> filledList = new ArrayList<ParcelableObjectSparseObjectEntry<Integer, String>>(
            2);

    AndroidCollections.iterate(mArray).but().keys(1, 2, 3).reverse().fillParcelable(filledList);

    assertThat(filledList).isEqualTo(parcelableList);

    final ParcelableObjectSparseObjectEntry[] filledArray = new ParcelableObjectSparseObjectEntry[2];

    AndroidCollections.iterate(mArray).only().value("2").fillParcelable(filledArray);

    assertThat(filledArray[0]).isEqualTo(SparseEntries.parcelableEntry(Integer.valueOf(2), "2"));

    AndroidCollections.iterate(mArray).only().value("2").fillParcelable(filledArray, 1);

    assertThat(filledArray[0]).isEqualTo(SparseEntries.parcelableEntry(Integer.valueOf(2), "2"));
    assertThat(filledArray[0]).isEqualTo(filledArray[1]);

    try {

        AndroidCollections.iterate(mArray).fillParcelable(filledArray);

        fail();

    } catch (final IndexOutOfBoundsException e) {

    }

    final Parcelable[] parcelables = new Parcelable[2];

    AndroidCollections.iterate(mArray).only().to(1).fillParcelable(parcelables);

    assertThat(parcelables).containsExactly(filledArray);
}