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.achep.base.ui.activities.SettingsActivity.java

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

    if (mCategories.size() > 0) {
        outState.putParcelableArrayList(SAVE_KEY_CATEGORIES, mCategories);
    }// w w w .j a  v  a  2 s .  com

    outState.putBoolean(SAVE_KEY_SHOW_HOME_AS_UP, mDisplayHomeAsUpEnabled);
}

From source file:org.thialfihar.android.apg.ui.ImportKeysActivity.java

/**
 * Import keys with mImportData//from   w w w .ja  v a2 s .c o  m
 */
public void importKeys() {
    // Message is received after importing is done in ApgService
    ApgIntentServiceHandler mSaveHandler = new ApgIntentServiceHandler(this,
            getString(R.string.progress_importing), ProgressDialog.STYLE_HORIZONTAL) {
        public void handleMessage(Message message) {
            // handle messages by standard ApgIntentServiceHandler first
            super.handleMessage(message);

            if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
                // get returned data bundle
                Bundle returnData = message.getData();

                int added = returnData.getInt(ApgIntentService.RESULT_IMPORT_ADDED);
                int updated = returnData.getInt(ApgIntentService.RESULT_IMPORT_UPDATED);
                int bad = returnData.getInt(ApgIntentService.RESULT_IMPORT_BAD);
                String toastMessage;
                if (added > 0 && updated > 0) {
                    String addedStr = getResources().getQuantityString(R.plurals.keys_added_and_updated_1,
                            added, added);
                    String updatedStr = getResources().getQuantityString(R.plurals.keys_added_and_updated_2,
                            updated, updated);
                    toastMessage = addedStr + updatedStr;
                } else if (added > 0) {
                    toastMessage = getResources().getQuantityString(R.plurals.keys_added, added, added);
                } else if (updated > 0) {
                    toastMessage = getResources().getQuantityString(R.plurals.keys_updated, updated, updated);
                } else {
                    toastMessage = getString(R.string.no_keys_added_or_updated);
                }
                AppMsg.makeText(ImportKeysActivity.this, toastMessage, AppMsg.STYLE_INFO).show();
                if (bad > 0) {
                    BadImportKeyDialogFragment badImportKeyDialogFragment = BadImportKeyDialogFragment
                            .newInstance(bad);
                    badImportKeyDialogFragment.show(getSupportFragmentManager(), "badKeyDialog");
                }
            }
        }
    };

    if (mListFragment.getKeyBytes() != null || mListFragment.getDataUri() != null) {
        Log.d(Constants.TAG, "importKeys started");

        // Send all information needed to service to import key in other thread
        Intent intent = new Intent(this, ApgIntentService.class);

        intent.setAction(ApgIntentService.ACTION_IMPORT_KEYRING);

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

        // get selected key entries
        ArrayList<ImportKeysListEntry> selectedEntries = mListFragment.getSelectedData();
        data.putParcelableArrayList(ApgIntentService.IMPORT_KEY_LIST, selectedEntries);

        intent.putExtra(ApgIntentService.EXTRA_DATA, data);

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

        // show progress dialog
        mSaveHandler.showProgressDialog(this);

        // start service with intent
        startService(intent);
    } else if (mListFragment.getServerQuery() != null) {
        // Send all information needed to service to query keys in other thread
        Intent intent = new Intent(this, ApgIntentService.class);

        intent.setAction(ApgIntentService.ACTION_DOWNLOAD_AND_IMPORT_KEYS);

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

        data.putString(ApgIntentService.DOWNLOAD_KEY_SERVER, mListFragment.getKeyServer());

        // get selected key entries
        ArrayList<ImportKeysListEntry> selectedEntries = mListFragment.getSelectedData();
        data.putParcelableArrayList(ApgIntentService.DOWNLOAD_KEY_LIST, selectedEntries);

        intent.putExtra(ApgIntentService.EXTRA_DATA, data);

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

        // show progress dialog
        mSaveHandler.showProgressDialog(this);

        // start service with intent
        startService(intent);
    } else {
        AppMsg.makeText(this, R.string.error_nothing_import, AppMsg.STYLE_ALERT).show();
    }
}

From source file:org.videolan.vlc.gui.browser.BaseBrowserFragment.java

public void browse(MediaWrapper media, int position) {
    FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
    Fragment next = createFragment();/*from  ww w.jav a  2  s  . c  o  m*/
    Bundle args = new Bundle();
    ArrayList<MediaWrapper> list = mMediaLists != null ? mMediaLists.get(position) : null;
    if (list != null && !list.isEmpty())
        args.putParcelableArrayList(KEY_MEDIA_LIST, list);
    args.putParcelable(KEY_MEDIA, media);
    next.setArguments(args);
    ft.replace(R.id.fragment_placeholder, next, media.getLocation());
    ft.addToBackStack(mMrl);
    ft.commit();
}

From source file:org.kiwix.kiwixmobile.ZimFileSelectActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {

    // Check, if the user has rescanned the file system, if he has, then we want to save this list,
    // so this can be shown again, if the activity is recreated (on a device rotation for example)
    if (!mFiles.isEmpty()) {
        Log.i(TAG_KIWIX, "Saved state of the ListView");
        outState.putParcelableArrayList("rescanData", mFiles);
    }/*from  ww  w  . jav a 2  s  .c o m*/
    super.onSaveInstanceState(outState);
}

From source file:com.pressurelabs.flowopensource.TheHubActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putParcelableArrayList(AppConstants.RESTORED_USER_FLOWS, rvContent);
    outState.putParcelable(AppConstants.RESTORED_DATA_MANAGER, manager);
    super.onSaveInstanceState(outState);
}

From source file:com.ushahidi.platform.mobile.app.presentation.view.ui.activity.AddPostActivity.java

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    savedInstanceState.putLong(BUNDLE_STATE_PARAM_FORM_ID, mFormId);
    savedInstanceState.putString(BUNDLE_STATE_PARAM_FORM_TITLE, mFormTitle);
    savedInstanceState.putParcelableArrayList(BUNDLE_STATE_PARAM_FORM_STEPS, (ArrayList) mFormStages);
    savedInstanceState.putParcelableArrayList(BUNDLE_STATE_PARAM_FORM_ATTRIBUTES,
            (ArrayList) mFormAttributeModels);
    super.onSaveInstanceState(savedInstanceState);
}

From source file:ca.spencerelliott.mercury.Changesets.java

@Override
public boolean onSearchRequested() {
    //If it's already a search window, block the search from happening again
    if (is_search_window)
        return false;

    //Create a new bundle to store the changeset data
    Bundle app_data = new Bundle();

    //Pack up the array list data in to a parcel
    app_data.putParcelableArrayList("ca.spencerelliott.mercury.SEARCH_DATA", changesets_data);

    //Start the search
    startSearch(null, false, app_data, false);
    return true;//  w  ww  .  ja  v a  2 s.c om
}

From source file:zack.yovel.clear.controller.foreground.MainActivity.java

private void handlerReportsSuccess(ArrayList<GeoName> suggestions) {
    // This is a bit dangerous. Throughout method definitions this
    // object has been up-casted to List, but knowing that it originated
    // as an array list I use an array list here. I don't know of any usage
    // of non-array lists, but if such a thing happens a class cast exception
    // may rise here. I do not catch it because this should not remain un-fixed
    // at run-time, this should be noticed and taken care of by the developer.
    // Yes, that huge comment referred to the above line only.
    Bundle args = new Bundle(2);
    SuggestionsDialogFragment suggestionsDialog = new SuggestionsDialogFragment();
    args.putString(SuggestionsDialogFragment.EXTRA_TITLE, getString(R.string.title_suggestions_dialog));
    args.putParcelableArrayList(SuggestionsDialogFragment.EXTRA_SUGGESTIONS_LIST, suggestions);
    suggestionsDialog.setArguments(args);
    suggestionsDialog.show(getSupportFragmentManager(), Constants.Tags.SUGGESTIONS);
}

From source file:org.videolan.vlc.gui.audio.AudioPlayer.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.playlist_save:
        if (!mClient.isConnected())
            return;
        FragmentManager fm = getActivity().getSupportFragmentManager();
        SavePlaylistDialog savePlaylistDialog = new SavePlaylistDialog();
        Bundle args = new Bundle();
        args.putParcelableArrayList(SavePlaylistDialog.KEY_TRACKS,
                (ArrayList<MediaWrapper>) mClient.getMedias());
        savePlaylistDialog.setArguments(args);
        savePlaylistDialog.show(fm, "fragment_save_playlist");
        break;//from  w ww  .ja v a 2 s.  com
    }
}

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

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Log.d(LOG_TAG, String.format("@%d -> Fragment(currentPage=%d) Saving '%d' posts / scrollPosition = '%d'",
            System.identityHashCode(this), currentPage, displayedPosts.size(), currentScrollPosition));

    outState.putParcelableArrayList(ARG_POST_LIST, displayedPosts);
    outState.putInt(ARG_SAVED_SCROLL_POSITION, currentScrollPosition);
}