List of usage examples for android.os Bundle getParcelableArray
@Nullable
public Parcelable[] getParcelableArray(@Nullable String key)
From source file:com.bmd.android.collection.SimpleArrayMapTest.java
public void testParcelable() { final ParcelableObjectSparseObjectEntry[] parcelableArray = AndroidCollections.iterate(mArray).only() .values("4", "1").toParcelableArray(ParcelableObjectSparseObjectEntry.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<ParcelableObjectSparseObjectEntry<Integer, 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(Integer.valueOf(4), "4"), SparseEntries.parcelableEntry(Integer.valueOf(0), "0")); final Bundle bundle = new Bundle(); bundle.putParcelableArray("array", parcelableArray); bundle.putParcelableArrayList("list", parcelableList); final Parcel parcel = Parcel.obtain(); bundle.writeToParcel(parcel, 0);// w w w. j a va 2 s. c o m 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<ParcelableObjectSparseObjectEntry<Integer, String>> filledList = new ArrayList<ParcelableObjectSparseObjectEntry<Integer, String>>( 2); AndroidCollections.iterate(mArray).but().keys(1, 2, 3).reverse().fillParcelable(filledList); assertThat(filledList).isEqualTo(parcelableList); final ParcelableObjectSparseObjectEntry[] filledArray = new ParcelableObjectSparseObjectEntry[2]; AndroidCollections.iterate(mArray).only().value("2").fillParcelable(filledArray); assertThat(filledArray[0]).isEqualTo(SparseEntries.parcelableEntry(Integer.valueOf(2), "2")); AndroidCollections.iterate(mArray).only().value("2").fillParcelable(filledArray, 1); assertThat(filledArray[0]).isEqualTo(SparseEntries.parcelableEntry(Integer.valueOf(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: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);/*w ww . ja va2 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<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: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 w w w .j a v a 2s .c o m 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:net.alexjf.tmm.fragments.ImmedTransactionStatsFragment.java
@Override public void onAsyncTaskResultSuccess(String taskId, Bundle resultData) { for (SimpleSeriesRenderer simpleRenderer : renderer.getSeriesRenderers()) { renderer.removeSeriesRenderer(simpleRenderer); }// ww w . j a v a 2s . c o m dataSet.clear(); catPercentageAdapter.clear(); catPercentageAdapter.setNotifyOnChange(false); String currencyCode = resultData.getString(KEY_CURRENCY); CurrencyUnit currency; if (currencyCode == null) { currency = CurrencyUnit.EUR; } else { currency = CurrencyUnit.getInstance(currencyCode); } Category[] categories = (Category[]) resultData.getParcelableArray(KEY_CATEGORIES); double[] values = resultData.getDoubleArray(KEY_VALUES); double totalValue = resultData.getDouble(KEY_TOTALVALUE); for (int i = 0; i < categories.length; i++) { Category category = categories[i]; double categoryTotalValue = values[i]; int color = colors[(categories.length - i - 1) % colors.length]; dataSet.add(category.getName(), categoryTotalValue); catPercentageAdapter.add(new CategoryPercentageInfo(category, Money.of(currency, categoryTotalValue, RoundingMode.HALF_EVEN), categoryTotalValue / totalValue, color)); SimpleSeriesRenderer seriesRenderer = new SimpleSeriesRenderer(); seriesRenderer.setColor(color); renderer.addSeriesRenderer(seriesRenderer); } catPercentageAdapter.sort(new CategoryPercentageInfo.PercentageComparator(true)); catPercentageAdapter.notifyDataSetChanged(); if (chartView != null) { chartView.repaint(); } categoryStatsTask = null; Utils.allowOrientationChanges(getActivity()); }
From source file:com.bmd.android.collection.LongSparseArrayTest.java
public void testParcelable() { if (VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN) { return;/*from www.j a v a 2s . c om*/ } 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); }
From source file:com.github.michalbednarski.intentslab.editor.IntentEditorActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load intent Parcelable[] uncastedIntentFilters = null; if (savedInstanceState != null) { // Saved instance state mEditedIntent = savedInstanceState.getParcelable("intent"); mComponentType = savedInstanceState.getInt("componentType"); mMethodId = savedInstanceState.getInt("methodId"); uncastedIntentFilters = savedInstanceState.getParcelableArray("intentFilters"); Object uncastedLocalState = savedInstanceState.get("localIEState"); if (uncastedLocalState instanceof LocalIntentEditorState) { mLocalState = (LocalIntentEditorState) uncastedLocalState; }// w w w . ja v a 2s.c o m } else if (isInterceptedIntent()) { // Intercept mEditedIntent = new Intent(getIntent()); mEditedIntent.setComponent(null); mComponentType = IntentEditorConstants.ACTIVITY; mMethodId = getCallingPackage() != null ? IntentEditorConstants.ACTIVITY_METHOD_STARTACTIVITYFORRESULT : IntentEditorConstants.ACTIVITY_METHOD_STARTACTIVITY; } else if (getIntent().hasExtra(Editor.EXTRA_VALUE)) { mEditedIntent = getIntent().getParcelableExtra(Editor.EXTRA_VALUE); mGenericEditorMode = true; } else { // Start of editor mEditedIntent = getIntent().getParcelableExtra(EXTRA_INTENT); mComponentType = getIntent().getIntExtra(EXTRA_COMPONENT_TYPE, IntentEditorConstants.ACTIVITY); mMethodId = getIntent().getIntExtra(EXTRA_METHOD_ID, 0); uncastedIntentFilters = getIntent().getParcelableArrayExtra(EXTRA_INTENT_FILTERS); if (mEditedIntent == null) { mEditedIntent = new Intent(); } // Restore instance state if (getIntent().getExtras() != null) { Object localState = getIntent().getExtras().get(EXTRA_LOCAL_STATE); if (localState instanceof LocalIntentEditorState) { mLocalState = (LocalIntentEditorState) localState; } } } // Manually cast array of intent filters if (uncastedIntentFilters != null) { try { mAttachedIntentFilters = new IntentFilter[uncastedIntentFilters.length]; for (int i = 0; i < uncastedIntentFilters.length; i++) { mAttachedIntentFilters[i] = (IntentFilter) uncastedIntentFilters[i]; } } catch (ClassCastException e) { Log.w(TAG, "Invalid intent filters"); mAttachedIntentFilters = null; } } // Setup tabs if (getResources().getBoolean(R.bool.use_master_detail)) { //if (getResources().getConfiguration().orientation == 2) { mergeFollowingTabs(getString(R.string.general), R.layout.intent_editor_general_with_extras, R.id.general, R.id.extras); } addTab(getString(R.string.general), new IntentGeneralFragment()); addTab(getString(R.string.intent_extras), new IntentExtrasFragment()); addTab(getString(R.string.flags), new IntentFlagsFragment()); allTabsAdded(); }
From source file:org.lyricue.android.Lyricue.java
/** * Called when the activity is first created. *//*w ww . java 2s . c o m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(TAG, "onCreate()"); activity = this; setContentView(R.layout.main); FragmentManager fragman = getSupportFragmentManager(); vib = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); if (savedInstanceState != null) { for (Fragment frag : fragman.getFragments()) { if (frag != null) { Log.d(TAG, frag.toString()); Log.d(TAG, frag.getClass().getName()); fragments.put(frag.getClass().getName(), frag); } } hosts = (HostItem[]) savedInstanceState.getParcelableArray("hosts"); profile = savedInstanceState.getString("profile"); playlistid = savedInstanceState.getLong("playlistid"); playlists_text = savedInstanceState.getStringArray("playlists_text"); playlists_id = savedInstanceState.getLongArray("playlists_id"); bibles_text = savedInstanceState.getStringArray("bibles_text"); bibles_id = savedInstanceState.getStringArray("bibles_id"); bibles_type = savedInstanceState.getStringArray("bibles_type"); ld = new LyricueDisplay(hosts); } LyricuePagerAdapter adapter = new LyricuePagerAdapter(fragman, activity, activity); pager = (ViewPager) findViewById(R.id.viewpager); pager.setAdapter(adapter); actionBar = getSupportActionBar(); ActionBar.TabListener tabListener = new ActionBar.TabListener() { public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { // When the tab is selected, switch to the // corresponding page in the ViewPager. pager.setCurrentItem(tab.getPosition()); } @Override public void onTabReselected(Tab arg0, FragmentTransaction arg1) { } @Override public void onTabUnselected(Tab arg0, FragmentTransaction arg1) { } }; Tab controlTab = actionBar.newTab().setText("Control").setTabListener(tabListener); actionBar.addTab(actionBar.newTab().setText(R.string.playlist).setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText(R.string.available).setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText(R.string.bible).setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText(R.string.display).setTabListener(tabListener)); actionBar.addTab(controlTab); pager.setOffscreenPageLimit(actionBar.getTabCount()); Resources res = getResources(); Configuration conf = res.getConfiguration(); boolean isLandscape = (conf.orientation == Configuration.ORIENTATION_LANDSCAPE); boolean isLarge = (conf.screenLayout & 0x4) == 0x4; Log.d(TAG, "Status:" + isLarge + ":" + isLandscape); if (isLarge && isLandscape) { activity.setQuickBar(false); actionBar.removeTab(controlTab); pager.setCurrentItem(0); } else { pager.setCurrentItem(4); } pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { getSupportActionBar().setSelectedNavigationItem(position); } }); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) getWindow().setStatusBarColor(Color.RED); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); thumbnail_width = Math.min(displaymetrics.widthPixels, displaymetrics.heightPixels) / 2; if (profile.equals("")) { getPrefs(); } }
From source file:com.microsoft.rightsmanagement.ui.PolicyPickerActivity.java
/** * Retrieve data from intent./*ww w .j a va 2s . c o m*/ * * @param bundle the bundle * @return the UI policy pick orientation info. */ private void parseBundleInput(Bundle bundle) { if (bundle.containsKey(REQUEST_ORIGINAL_TEMPLATE_DESCRIPTOR_ITEM)) { Logger.d(TAG, "parseBundleInput - parsing OriginalTemplateDescriptorItem"); Parcelable requestOriginalTemplateDescriptor = bundle .getParcelable(PolicyPickerActivity.REQUEST_ORIGINAL_TEMPLATE_DESCRIPTOR_ITEM); if (requestOriginalTemplateDescriptor != null) { Logger.ie(TAG, "requestOriginalTemplateDescriptor is null"); } try { mOriginalTemplateDescriptorItem = (TemplateDescriptorModel) requestOriginalTemplateDescriptor; } catch (ClassCastException ex) { Logger.ie(TAG, ex.getMessage()); throw ex; } } if (bundle.containsKey(REQUEST_TEMPLATE_DESCRIPTOR_ITEM_ARRAY)) { Logger.d(TAG, "parseBundleInput - parsing TemplateDescriptorItemArray"); Parcelable[] requestArray = bundle .getParcelableArray(PolicyPickerActivity.REQUEST_TEMPLATE_DESCRIPTOR_ITEM_ARRAY); try { Object[] requestObjectArray = requestArray; mTemplateDescriptorItemArray = Arrays.copyOf(requestObjectArray, requestObjectArray.length, TemplateDescriptorModel[].class); } catch (ClassCastException ex) { Logger.ie(TAG, ex.getMessage()); throw ex; } } if (bundle.containsKey(REQUEST_CALLBACK_ID)) { Logger.d(TAG, "parseBundleInput - parsing RequestCallbackId"); mRequestCallbackId = bundle.getInt(REQUEST_CALLBACK_ID); } if (bundle.containsKey(CURRENT_SELECTED_TEMPLATE_DESCRIPTOR_INDEX)) { Logger.d(TAG, "parseBundleInput - parsing CurrentSelectedtemplateDescriptorItemIndex"); mCurrentSelectedtemplateDescriptorItemIndex = bundle.getInt(CURRENT_SELECTED_TEMPLATE_DESCRIPTOR_INDEX); } }
From source file:de.spiritcroc.ownlog.ui.fragment.LogItemEditFragment.java
private boolean restoreValues(Bundle savedInstanceState) { if (savedInstanceState == null) { return false; }/*from w w w . j av a 2s. c o m*/ try { if (savedInstanceState.containsKey(KEY_INIT_TITLE)) { mInitTitle = savedInstanceState.getString(KEY_INIT_TITLE); mEditLogTitle.setText(savedInstanceState.getString(KEY_SET_TITLE)); mInitContent = savedInstanceState.getString(KEY_INIT_CONTENT); mEditLogContent.setText(savedInstanceState.getString(KEY_SET_CONTENT)); mInitTime = savedInstanceState.getLong(KEY_INIT_TIME); mTime = Calendar.getInstance(); mTime.setTimeInMillis(savedInstanceState.getLong(KEY_SET_TIME)); mInitTags = new ArrayList<>( Arrays.asList((TagItem[]) savedInstanceState.getParcelableArray(KEY_INIT_TAGS))); mSetTags = new ArrayList<>( Arrays.asList((TagItem[]) savedInstanceState.getParcelableArray(KEY_SET_TAGS))); mAvailableTags = new ArrayList<>( Arrays.asList((TagItem[]) savedInstanceState.getParcelableArray(KEY_AVAILABLE_TAGS))); updateTitle(); mEditTagsView.updateContent(); return true; } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:de.spiritcroc.ownlog.ui.fragment.LogFilterEditFragment.java
private boolean restoreValues(Bundle savedInstanceState) { if (savedInstanceState == null) { return false; }//from w ww . ja va 2 s . c o m try { if (savedInstanceState.containsKey(KEY_ADD_ITEM)) { mAddItem = savedInstanceState.getBoolean(KEY_ADD_ITEM); mEditItemId = savedInstanceState.getLong(KEY_EDIT_ITEM_ID); mInitName = savedInstanceState.getString(KEY_INIT_NAME); mEditName.setText(savedInstanceState.getString(KEY_SET_NAME)); mInitStrictFilterTags = savedInstanceState.getBoolean(KEY_INIT_STRICT_TAG_FILTER); mCheckStrictFilterTags.setChecked(savedInstanceState.getBoolean(KEY_SET_STRICT_TAG_FILTER)); mInitSortOrder = savedInstanceState.getString(KEY_INIT_SORT_ORDER); mSortOrder = savedInstanceState.getInt(KEY_SORT_ORDER); mInitTags = new ArrayList<>( Arrays.asList((TagItem[]) savedInstanceState.getParcelableArray(KEY_INIT_TAGS))); mInitExcludedTags = new ArrayList<>( Arrays.asList((TagItem[]) savedInstanceState.getParcelableArray(KEY_INIT_EXCLUDED_TAGS))); mSetTags = new ArrayList<>( Arrays.asList((TagItem[]) savedInstanceState.getParcelableArray(KEY_SET_TAGS))); mExcludedTags = new ArrayList<>( Arrays.asList((TagItem[]) savedInstanceState.getParcelableArray(KEY_EXCLUDED_TAGS))); mAvailableTags = new ArrayList<>( Arrays.asList((TagItem[]) savedInstanceState.getParcelableArray(KEY_AVAILABLE_TAGS))); mSortOrder = Arrays.asList(mSortOrderValues).indexOf(mInitSortOrder); if (mSortOrder < 0) { // Select default sort order mSortOrder = 0; } mSpinSortOrder.setSelection(mSortOrder); mEditTagsView.updateContent(); mEditExcludedTagsView.updateContent(); updateStrictFilterTagsInfo(); return true; } } catch (Exception e) { e.printStackTrace(); } return false; }