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.lloydtorres.stately.telegrams.TelegramReadActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    // Save state
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putInt(ID_DATA, id);
    if (title != null) {
        savedInstanceState.putString(TITLE_DATA, title);
    }/*from  w w  w . j a v a  2s .  c o  m*/
    if (telegrams != null) {
        savedInstanceState.putParcelableArrayList(TELEGRAM_DATA, telegrams);
    }
}

From source file:com.google.samples.apps.gameloopmanager.TestLoopsActivity.java

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

    outState.putIntegerArrayList(CHECKED_SCENARIOS, new ArrayList<>(checkedScenarios));
    outState.putParcelableArrayList(TEST_LOOP_GROUPS, testLoopGroups);
}

From source file:de.gruenewald.udacity.spotifystreamer.controller.AppController.java

/**
 * This function will be called when a track from the track list is separated.
 * It will then launch a {@link PlaybackFragment} either as fragment or as dialog
 * depending on the device specification (tablet / phone).
 *
 * @param pTrackPosition The position of the Item which was selected.
 * @param pIsTabletMode  A boolean indicating whether the device is a tablet or not.
 * @throws MissingDependencyException Will be thrown if a required dependency is missing.
 * @throws ParameterException         Will be thrown if a provided parameter is invalid.
 *//*w  w w .jav  a  2s .  c  o  m*/
public void handleOnTrackSelected(final int pTrackPosition, final boolean pIsTabletMode)
        throws MissingDependencyException, ParameterException {
    if (pTrackPosition <= -1) {
        throw new ParameterException("Can't execute 'handleOnTrackSelected'. Invalid track's position.");
    }

    if (mArtistListPosition <= -1) {
        throw new MissingDependencyException(
                "Can't execute 'handleOnTrackSelected'. Missing dependency: 'ArtistListPosition'.");
    }

    //we'll use this dependency to fetch the currently displayed tracklist which will then be
    //passed to the PlaybackFragment
    if (mTrackFragment == null) {
        throw new MissingDependencyException(
                "Can't execute: 'handleOnTrackSelected'. Missing dependency: 'TrackFragment'.");
    }

    //we'll use this dependency to fetch the currently selected artist (which links to the
    //tracklist) and which will be passed to the PlaybackFragment
    if (mArtistFragment == null) {
        throw new MissingDependencyException(
                "Can't execute: 'handleOnTrackSelected'. Missing dependency: 'ArtistFragment'.");
    }

    //if we are in table-mode we need the MainActivity to register the PlaybackFragment on.
    if (pIsTabletMode && mMainActivity == null) {
        throw new MissingDependencyException(
                "Can't execute: 'handleOnTrackSelected'. Missing dependency: 'MainActivity'.");
    }

    //if we are in phone-mode we need the TrackActivity to register the PlaybackFragment on.
    if (!pIsTabletMode && mTrackActivity == null) {
        throw new MissingDependencyException(
                "Can't execute 'handleOnTrackSelected.'. Missing dependency: 'TrackActivity'.");
    }

    ArrayList<PlaybackEntry> myPlaybackEntries = new ArrayList<PlaybackEntry>();

    //fetch the playback-entries from the currently displayed track-list
    for (TrackListEntry myEntry : mTrackFragment.getTrackListEntries()) {
        PlaybackEntry myNewPlaybackEntry = new PlaybackEntry();
        myNewPlaybackEntry.setArtistListEntry(mArtistFragment.getArtistListEntries().get(mArtistListPosition));
        myNewPlaybackEntry.setTrackListEntry(myEntry);
        myPlaybackEntries.add(myNewPlaybackEntry);
    }

    //prepare the data bundle for the playback fragment
    Bundle myDataBundle = new Bundle();
    myDataBundle.putInt(PlaybackFragment.ARG_PLAYBACK_TRACKINDEX, pTrackPosition);
    myDataBundle.putParcelableArrayList(PlaybackFragment.ARG_PLAYBACK_DATALIST, myPlaybackEntries);

    //register the PlaybackFragment
    registerPlaybackFragment(PlaybackFragment.newInstance(myDataBundle));

    //launch the PlaybackFragment depending on whether we are running on tablet or phone
    //remove any existing PlaybackFragment's which might have been registered previously
    //(that should not happen)
    if (!pIsTabletMode) {
        FragmentManager myFM = mTrackActivity.getSupportFragmentManager();
        FragmentTransaction myFT = myFM.beginTransaction();

        Fragment myExisting = myFM.findFragmentByTag(TRACK_PLAYBACK_TAG);
        if (myExisting != null) {
            Log.w(LOG_TAG, "Had to remove a previously existing PlaybackFragment.");
            myFT.remove(myExisting);
        }

        myFT.replace(R.id.fragment_playback_container, mPlaybackFragment, TRACK_PLAYBACK_TAG)
                .addToBackStack(null).commit();
    } else {
        FragmentManager myFM = mMainActivity.getSupportFragmentManager();
        FragmentTransaction myFT = myFM.beginTransaction();

        Fragment myExisting = myFM.findFragmentByTag(TRACK_PLAYBACK_TAG);
        if (myExisting != null) {
            Log.w(LOG_TAG, "Had to remove a previously existing PlaybackFragment.");
            myFT.remove(myExisting);
        }

        myFT.addToBackStack(null);
        mPlaybackFragment.show(myFT, TRACK_PLAYBACK_TAG);
    }
}

From source file:net.yolosec.upckeygen.ui.NetworkFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (passwordList != null) {
        outState.putParcelableArrayList(PASSWORD_LIST, passwordList);
    }/*  w  ww .j  ava  2s  .c  o  m*/
}

From source file:com.example.mahendran.moviecritic.DetailFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    ArrayList<Trailer> trailers = mTrailerAdapter.getTrailers();
    if (trailers != null && !trailers.isEmpty()) {
        outState.putParcelableArrayList(EXTRA_TRAILERS, trailers);
    }// w w  w .jav a 2s .  c  om

    ArrayList<Review> reviews = mReviewAdapter.getReviews();
    if (reviews != null && !reviews.isEmpty()) {
        outState.putParcelableArrayList(EXTRA_REVIEWS, reviews);
    }
}

From source file:com.ayuget.redface.ui.fragment.TopicListFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelableArrayList(ARG_TOPIC_LIST, displayedTopics);
    outState.putInt(ARG_LAST_LOADED_PAGE, lastLoadedPage);
}

From source file:com.antew.redditinpictures.library.ui.ImageViewerActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putParcelableArrayList(Constants.Extra.EXTRA_ENTRIES, (ArrayList<? extends Parcelable>) mImages);
    outState.putBoolean(Constants.Extra.EXTRA_IS_SWIPING_ENABLED, mPager.isSwipingEnabled());
    outState.putInt(Constants.Extra.EXTRA_IMAGE, mPager.getCurrentItem());
    super.onSaveInstanceState(outState);
}

From source file:org.sufficientlysecure.keychain.ui.CreateKeyYubiKeyImportFragment.java

public void importKey() {

    // Message is received after decrypting is done in KeychainService
    ServiceProgressHandler saveHandler = new ServiceProgressHandler(getActivity(),
            getString(R.string.progress_importing), ProgressDialog.STYLE_HORIZONTAL) {
        @Override//from  ww w.j av a2s .  c  o  m
        public void handleMessage(Message message) {
            // handle messages by standard KeychainIntentServiceHandler first
            super.handleMessage(message);

            if (message.arg1 == MessageStatus.OKAY.ordinal()) {
                // get returned data bundle
                Bundle returnData = message.getData();

                ImportKeyResult result = returnData.getParcelable(DecryptVerifyResult.EXTRA_RESULT);

                long[] masterKeyIds = result.getImportedMasterKeyIds();

                // TODO handle masterKeyIds.length != 1...? sorta outlandish scenario

                if (!result.success() || masterKeyIds.length == 0) {
                    result.createNotify(getActivity()).show();
                    return;
                }

                Intent intent = new Intent(getActivity(), ViewKeyActivity.class);
                // use the imported masterKeyId, not the one from the yubikey, because
                // that one might* just have been a subkey of the imported key
                intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyIds[0]));
                intent.putExtra(ViewKeyActivity.EXTRA_DISPLAY_RESULT, result);
                intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, mNfcAid);
                intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, mNfcUserId);
                intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, mNfcFingerprints);
                startActivity(intent);
                getActivity().finish();

            }

        }
    };

    // Send all information needed to service to decrypt in other thread
    Intent intent = new Intent(getActivity(), KeychainService.class);

    // fill values for this action
    Bundle data = new Bundle();

    intent.setAction(KeychainService.ACTION_IMPORT_KEYRING);

    ArrayList<ParcelableKeyRing> keyList = new ArrayList<>();
    keyList.add(new ParcelableKeyRing(mNfcFingerprint, null, null));
    data.putParcelableArrayList(KeychainService.IMPORT_KEY_LIST, keyList);

    {
        Preferences prefs = Preferences.getPreferences(getActivity());
        Preferences.CloudSearchPrefs cloudPrefs = new Preferences.CloudSearchPrefs(true, true,
                prefs.getPreferredKeyserver());
        data.putString(KeychainService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
    }

    intent.putExtra(KeychainService.EXTRA_DATA, data);

    // Create a new Messenger for the communication back
    Messenger messenger = new Messenger(saveHandler);
    intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);

    saveHandler.showProgressDialog(getActivity());

    // start service with intent
    getActivity().startService(intent);

}

From source file:org.gdg.frisbee.android.activity.MainActivity.java

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

    if (mSpinnerAdapter.getCount() > 0)
        outState.putParcelableArrayList("chapters", mSpinnerAdapter.getAll());
    if (mViewPagerAdapter.getSelectedChapter() != null)
        outState.putParcelable("selected_chapter", mViewPagerAdapter.getSelectedChapter());
}

From source file:com.wglxy.example.dashL.SearchActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    storeTemp();/*  ww w. j av a2 s .  c  o m*/
    outState.putString(KEY_SEARCH_QUERY, searchStr);
    outState.putParcelableArrayList(KEY_USER_OBJ, data);
}