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.sababado.support.v4.app.SearchableSupportListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    //Save the search view's text and visibility
    outState.putInt("search_visibility", mSearchView.getVisibility());
    outState.putString("search_text", mSearchView.getText().toString());
    //If custom adapter, save state.
    if (mFilterableAdapter != null) {
        ArrayList<? extends Parcelable> list = mFilterableAdapter.saveInstanceState();
        if (list != null)
            outState.putParcelableArrayList("list", list);
    }//from w w w.j a  v a2 s. c  om
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.InAppFlashingFragment.java

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

    outState.putParcelableArrayList(EXTRA_PENDING_ACTIONS, mPendingActions);

    outState.putParcelable(EXTRA_SELECTED_URI, mSelectedUri);
    outState.putString(EXTRA_SELECTED_URI_FILE_NAME, mSelectedUriFileName);
    outState.putParcelable(EXTRA_SELECTED_BACKUP_DIR_URI, mSelectedBackupDirUri);
    outState.putString(EXTRA_SELECTED_BACKUP_NAME, mSelectedBackupName);
    outState.putStringArray(EXTRA_SELECTED_BACKUP_TARGETS, mSelectedBackupTargets);
    outState.putString(EXTRA_SELECTED_ROM_ID, mSelectedRomId);
    outState.putString(EXTRA_ZIP_ROM_ID, mZipRomId);
    outState.putSerializable(EXTRA_ADD_TYPE, mAddType);
    outState.putInt(EXTRA_TASK_ID_VERIFY_ZIP, mTaskIdVerifyZip);
    outState.putBoolean(EXTRA_QUERYING_METADATA, mQueryingMetadata);
}

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

public void testParcelable() {

    final ParcelableIntSparseObjectEntry[] parcelableArray = AndroidCollections.iterate(mArray).only()
            .values("4", "1").toParcelableArray(ParcelableIntSparseObjectEntry.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<ParcelableIntSparseObjectEntry<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(4, "4"),
            SparseEntries.parcelableEntry(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 w  w.  ja v  a2s  .  com

    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<ParcelableIntSparseObjectEntry<String>> filledList = new ArrayList<ParcelableIntSparseObjectEntry<String>>(
            2);

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

    assertThat(filledList).isEqualTo(parcelableList);

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

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

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

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

    assertThat(filledArray[0]).isEqualTo(SparseEntries.parcelableEntry(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);
}

From source file:de.uni_koblenz_landau.apow.ObsDetailFragment.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putInt(ARG_FINDING_CODE, findingCode);
    savedInstanceState.putInt(ARG_SYMPTOM_CODE, symptomCode);
    savedInstanceState.putSerializable(ARG_OBS, mObs);
    savedInstanceState.putParcelableArrayList(ARG_TEST_CONCEPTS, (ArrayList<ListViewItem>) mTestConcepts);
}

From source file:com.example.alvarpao.popularmovies.MovieGridFragment.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {

    mSavedMovies.clear();/*w  w  w .  j  a v a  2s . co m*/
    for (int index = 0; index < mMovieAdapter.getCount(); index++)
        mSavedMovies.add(mMovieAdapter.getItem(index));
    //Toast.makeText(getActivity(), "Number of movies saved: " + mSavedMovies.size(),
    // Toast.LENGTH_SHORT).show();
    savedInstanceState.putParcelableArrayList(LOADED_MOVIES, mSavedMovies);
    savedInstanceState.putInt(PAGE_TO_FETCH, mPageToFetch);
    savedInstanceState.putInt(LOADED_PREVIOUS_ITEMS, mPreviousTotalItems);
    // The user actually selected a movie, it was not pre-selected by the app to keep the
    // details fragment from being empty in the two-pane layout
    if ((mSelectedMovie != -1) && (mSelectionOccurred))
        savedInstanceState.putInt(SELECTED_MOVIE, mSelectedMovie);
    else {
        // No movie selected save the position of the first visible item
        //Toast.makeText(getActivity(), "No position selected, select first visible",
        // Toast.LENGTH_SHORT).show();
        savedInstanceState.putInt(SELECTED_MOVIE, mMoviesGridView.getFirstVisiblePosition());
    }
    savedInstanceState.putBoolean(SELECTION_OCCURRED, mSelectionOccurred);
    savedInstanceState.putInt(CURRENT_SCROLL_POSITION, mMoviesGridView.getFirstVisiblePosition());

    super.onSaveInstanceState(savedInstanceState);
}

From source file:com.lloydtorres.stately.telegrams.TelegramsFragment.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    // Save state
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putInt(KEY_PAST_OFFSET, pastOffset);
    savedInstanceState.putInt(KEY_ACTIVE, selectedFolder);
    if (telegrams != null) {
        savedInstanceState.putParcelableArrayList(KEY_TELEGRAMS, telegrams);
    }//from   w  w w . j  a v a 2s .c  o m
    if (folders != null) {
        savedInstanceState.putParcelableArrayList(KEY_FOLDERS, folders);
    }
}

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

public void testParcelable() {

    final ParcelableLongSparseObjectEntry[] parcelableArray = AndroidCollections.iterate(mArray).only()
            .values("4", "1").toParcelableArray(ParcelableLongSparseObjectEntry.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<ParcelableLongSparseObjectEntry<String>> parcelableList = AndroidCollections.iterate(mArray)
            .but().keys(Arrays.asList(1L, 2L, 3L)).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(4L, "4"),
            SparseEntries.parcelableEntry(0L, "0"));

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

    final Parcel parcel = Parcel.obtain();
    bundle.writeToParcel(parcel, 0);/*from   www.j  av a2 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<ParcelableLongSparseObjectEntry<String>> filledList = new ArrayList<ParcelableLongSparseObjectEntry<String>>(
            2);

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

    assertThat(filledList).isEqualTo(parcelableList);

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

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

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

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

    assertThat(filledArray[0]).isEqualTo(SparseEntries.parcelableEntry(2L, "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);
}

From source file:com.krayzk9s.imgurholo.ui.ImagesFragment.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putStringArrayList("urls", urls);
    savedInstanceState.putParcelableArrayList("ids", ids);
    // Always call the superclass so it can save the view hierarchy state
    super.onSaveInstanceState(savedInstanceState);
}

From source file:de.sourcestream.movieDB.controller.SearchList.java

/**
 * Called to ask the fragment to save its current dynamic state,
 * so it can later be reconstructed in a new instance of its process is restarted.
 *
 * @param outState Bundle in which to place your saved state.
 *//*from w  w w .  jav a2  s .c om*/
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    // Used to avoid bug where we add item in the back stack
    // and if we change orientation twice the item from the back stack has null values
    if (save != null)
        outState.putBundle("save", save);
    else {
        Bundle send = new Bundle();
        send.putInt("totalPages", totalPages);
        send.putString("title", getTitle());
        if (backState == 1) {
            send.putInt("backState", 1);
            send.putParcelableArrayList("listData", searchList);
            // used to restore the scroll listener variables
            send.putInt("currentPage", endlessScrollListener.getCurrentPage());
            send.putInt("oldCount", endlessScrollListener.getOldCount());
            send.putBoolean("loading", endlessScrollListener.getLoading());
            // Save scroll position
            if (listView != null) {
                Parcelable listState = listView.onSaveInstanceState();
                send.putParcelable("listViewScroll", listState);
            }
        } else {
            send.putInt("backState", 0);
            send.putString("query", query);
        }
        outState.putBundle("save", send);
    }
}

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

public void testParcelable() {

    if (VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN) {

        return;/* w  w w  .j av a  2s.co  m*/
    }

    final ParcelableLongSparseObjectEntry[] parcelableArray = AndroidCollections.iterate(mArray).only()
            .values("4", "1").toParcelableArray(ParcelableLongSparseObjectEntry.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<ParcelableLongSparseObjectEntry<String>> parcelableList = AndroidCollections.iterate(mArray)
            .but().keys(Arrays.asList(1L, 2L, 3L)).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(4L, "4"),
            SparseEntries.parcelableEntry(0L, "0"));

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

    final Parcel parcel = Parcel.obtain();
    bundle.writeToParcel(parcel, 0);

    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<ParcelableLongSparseObjectEntry<String>> filledList = new ArrayList<ParcelableLongSparseObjectEntry<String>>(
            2);

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

    assertThat(filledList).isEqualTo(parcelableList);

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

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

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

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

    assertThat(filledArray[0]).isEqualTo(SparseEntries.parcelableEntry(2L, "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);
}