@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(KEY_ITEM_SELECTED, mItemSelected); outState.putString(KEY_WHERE_CLAUSE, getWhereClause()); if (mDateFrom != null) { // outState.putSerializable(KEY_FROM_DATE, mDateFrom); outState.putString(KEY_FROM_DATE, mDateFrom.toString()); } if (mDateTo != null) outState.putSerializable(KEY_TO_DATE, mDateTo); }
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); // inflate menu inflater.inflate(R.menu.menu_report, menu); inflater.inflate(R.menu.menu_period_picker, menu); // checked item MenuItem item = menu.findItem(mItemSelected); if (item != null) { item.setChecked(true); } }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // set list view setHasOptionsMenu(true); setEmptyText(getString(R.string.no_data)); setListShown(false); // Restore instance state. if (savedInstanceState != null) { if (savedInstanceState.containsKey(KEY_ITEM_SELECTED)) mItemSelected = savedInstanceState.getInt(KEY_ITEM_SELECTED); if (savedInstanceState.containsKey(KEY_FROM_DATE)) { // mDateFrom = (Date) savedInstanceState.getSerializable(KEY_FROM_DATE); String dateFromString = savedInstanceState.getString(KEY_FROM_DATE); mDateFrom = new DateTime(dateFromString); } if (savedInstanceState.containsKey(KEY_TO_DATE)) mDateTo = (Date) savedInstanceState.getSerializable(KEY_TO_DATE); } // start loader startLoader(savedInstanceState); }