下面列出了android.os.Bundle#putParcelableArrayList ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static BypassedAndOfflineDeviceScrollablePopup newInstance(Version1ButtonColor topButtonColor,
String topButtonText, Version1ButtonColor bottomButtonColor, String bottomButtonText,
ArrayList<AlertDeviceStateModel> deviceStateModelList,
BypassedAndOfflineDeviceScrollablePopup.Callback callback) {
BypassedAndOfflineDeviceScrollablePopup fragment = new BypassedAndOfflineDeviceScrollablePopup();
Bundle bundle = new Bundle();
bundle.putSerializable(TOP_COLOR_KEY, topButtonColor);
bundle.putSerializable(TOP_TITLE_KEY, topButtonText);
bundle.putSerializable(BOTTOM_COLOR_KEY, bottomButtonColor);
bundle.putSerializable(BOTTOM_TITLE_KEY, bottomButtonText);
bundle.putParcelableArrayList(DEVICES, deviceStateModelList);
fragment.setArguments(bundle);
fragment.callback = callback;
return fragment;
}
private void route(int position, MyPoiModel poiInfo) {
AppUtils.closeKeyboard(mEditSearch, this);
Bundle bundle = new Bundle();
if ("MainActivity".equals(mFrom) && !(poiInfo.getTypePoi() == TypePoi.BUS_LINE || poiInfo.getTypePoi() == TypePoi.SUBWAY_LINE)) {
if (null != mResultAdapter) {
bundle.putParcelableArrayList("poiAll", (ArrayList<MyPoiModel>) mResultAdapter.getList());
}
bundle.putInt("position", position);
} else {
bundle.putParcelable("poi", poiInfo);
}
Intent intent = new Intent();
intent.putExtras(bundle);
setResult(MainActivity.REQUEST_SEARCH, intent);
finish();
}
/**
* Saves the state of all SuperToasts that are showing and/or pending.
*
* This should be called in the {@link android.app.Activity#onSaveInstanceState(android.os.Bundle)}
* method of your Activity.
*
* @param bundle The Bundle provided in onSaveInstanceState()
*/
@SuppressWarnings("unchecked")
public static void onSaveState(Bundle bundle) {
final ArrayList<Style> styleList = new ArrayList();
// Create a list of every Style used by a SuperToast in the queue
for (SuperToast superToast : Toaster.getInstance().getQueue()) {
if (superToast instanceof SuperActivityToast) {
superToast.getStyle().isSuperActivityToast = true;
}
styleList.add(superToast.getStyle());
}
bundle.putParcelableArrayList(BUNDLE_KEY, styleList);
// Let's avoid any erratic behavior and cancel any showing/pending SuperActivityToasts manually
Toaster.getInstance().cancelAllSuperToasts();
}
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putParcelableArrayList("infoList", infoList);
if (mPosition != ListView.INVALID_POSITION) {
outState.putInt(SELECTED_KEY, mPosition);
}
super.onSaveInstanceState(outState);
}
/**
* 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.
*/
@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("checkLoadMore", checkLoadMore);
send.putInt("totalPages", totalPages);
send.putString("currentListURL", getCurrentList());
send.putString("title", getTitle());
send.putBoolean("isLoading", isLoading);
send.putInt("lastVisitedTV", lastVisitedTV);
if (backState == 1) {
send.putInt("backState", 1);
send.putParcelableArrayList("listData", tvList);
// 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);
outState.putBundle("save", send);
}
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_insertdata) {
fragment=new InsertFragment();
} else if (id == R.id.nav_viewdata) {
fragment=new DisplayFragment();
ArrayList<Data> output=(ArrayList)database.readData();
Bundle bundle=new Bundle();
bundle.putParcelableArrayList("data",output);
bundle.putString(" ",output.toString());
fragment.setArguments(bundle);
}
if(fragment!=null)
{
FragmentTransaction ft=getSupportFragmentManager().beginTransaction();
ft.replace(R.id.content_main,fragment);
ft.commit();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
public static void show(
FragmentManager fragmentManager, ArrayList<BarcodeField> barcodeFieldArrayList) {
BarcodeResultFragment barcodeResultFragment = new BarcodeResultFragment();
Bundle bundle = new Bundle();
bundle.putParcelableArrayList(ARG_BARCODE_FIELD_LIST, barcodeFieldArrayList);
barcodeResultFragment.setArguments(bundle);
barcodeResultFragment.show(fragmentManager, TAG);
}
@NonNull
public static AddToPlaylistDialog create(List<Song> songs) {
AddToPlaylistDialog dialog = new AddToPlaylistDialog();
Bundle args = new Bundle();
args.putParcelableArrayList("songs", new ArrayList<>(songs));
dialog.setArguments(args);
return dialog;
}
private Bundle toBundle() {
Bundle arguments = new Bundle();
arguments.putParcelableArrayList(ARGUMENT_INDEX_ITEMS, itemsToIndex);
arguments.putBoolean(ARGUMENT_HISTORY_ENABLED, historyEnabled);
arguments.putParcelable(ARGUMENT_REVEAL_ANIMATION_SETTING, revealAnimationSetting);
arguments.putBoolean(ARGUMENT_FUZZY_ENABLED, fuzzySearchEnabled);
arguments.putBoolean(ARGUMENT_BREADCRUMBS_ENABLED, breadcrumbsEnabled);
arguments.putBoolean(ARGUMENT_SEARCH_BAR_ENABLED, searchBarEnabled);
arguments.putString(ARGUMENT_TEXT_HINT, textHint);
arguments.putString(ARGUMENT_TEXT_CLEAR_HISTORY, textClearHistory);
arguments.putString(ARGUMENT_TEXT_NO_RESULTS, textNoResults);
return arguments;
}
public static PickCalendarDialogFragment newInstance(ArrayList<Integer> indices,
ArrayList<String> calendars, ArrayList<ContentValues> valuesList) {
PickCalendarDialogFragment pcdf = new PickCalendarDialogFragment();
Bundle args = new Bundle();
args.putIntegerArrayList("indices", indices);
args.putStringArrayList("calendars", calendars);
args.putParcelableArrayList("valuesList", valuesList);
pcdf.setArguments(args);
return pcdf;
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
/**
* Code below to save all the fragment's state
*/
if (fragment != null) {
getFragmentManager().putFragment(outState, KEY_ONE, fragment);
}
outState.putString(KEY_TWO, mUserUID);
outState.putString(KEY_THREE, mHeaderKey);
if (qqOldHeaderKey != null) {
outState.putString(KEY_MM_ONE, qqOldHeaderKey);
}
if (qqUserUid != null) {
outState.putString(KEY_MM_TWO, qqUserUid);
}
if (qqSalesHeaderModel != null) {
outState.putParcelable(KEY_MM_THREE, qqSalesHeaderModel);
}
if (qqSalesDetailModelList != null) {
outState.putParcelableArrayList(KEY_MM_FOUR, qqSalesDetailModelList);
}
if (qqCashPaid != null) {
outState.putString(KEY_MM_FIVE, qqCashPaid);
}
if (qqChangeCash != null) {
outState.putString(KEY_MM_SIX, qqChangeCash);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putParcelableArrayList("matchListA", matchListA);
outState.putParcelableArrayList("matchListB", matchListB);
if (mPositionA != ListView.INVALID_POSITION) {
outState.putInt(SELECTED_KEY_A, mPositionA);
}
if (mPositionB != ListView.INVALID_POSITION) {
outState.putInt(SELECTED_KEY_B, mPositionB);
}
super.onSaveInstanceState(outState);
}
@NonNull
public static DeletePlaylistDialog create(ArrayList<Playlist> playlists) {
DeletePlaylistDialog dialog = new DeletePlaylistDialog();
Bundle args = new Bundle();
args.putParcelableArrayList("playlists", playlists);
dialog.setArguments(args);
return dialog;
}
@NonNull
public static DeletePlaylistDialog create(ArrayList<Playlist> playlists) {
DeletePlaylistDialog dialog = new DeletePlaylistDialog();
Bundle args = new Bundle();
args.putParcelableArrayList("playlists", playlists);
dialog.setArguments(args);
return dialog;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(TOP_OF_LIST, mLayoutManager.findFirstVisibleItemPosition());
outState.putParcelableArrayList(STORY_LIST, getViewModel().getStoryList());
}
@Override
protected void onSaveInstanceState(Bundle state) {
super.onSaveInstanceState(state);
state.putParcelableArrayList(CAROUSEL_DATA_KEY, (ArrayList<? extends Parcelable>) carousels);
controller.onSaveInstanceState(state);
}
@Override
public void saveItems(Bundle state, ArrayList<Parcelable> items) {
state.putParcelableArrayList(SAVE_KEY, items);
}
protected void onSaveInstanceState(Bundle outState) {
outState.putParcelableArrayList(TEMP_WALLPAPER_TILES, mTempWallpaperTiles);
outState.putInt(SELECTED_INDEX, mSelectedIndex);
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelableArrayList(PreferenceUtil.LIBRARY_CATEGORIES, new ArrayList<>(adapter.getCategoryInfos()));
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelableArrayList(BUNDLE_KEY, mSportsData);
}