Java Code Examples for android.os.Bundle#getSparseParcelableArray()
The following examples show how to use
android.os.Bundle#getSparseParcelableArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseScene.java From MHViewer with Apache License 2.0 | 6 votes |
public final View createDrawerView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { drawerView = onCreateDrawerView(inflater, container, savedInstanceState); if (drawerView != null) { SparseArray<Parcelable> saved = drawerViewState; if (saved == null && savedInstanceState != null) { saved = savedInstanceState.getSparseParcelableArray(KEY_DRAWER_VIEW_STATE); } if (saved != null) { drawerView.restoreHierarchyState(saved); } } return drawerView; }
Example 2
Source File: MenuBuilder.java From zhangshangwuda with Apache License 2.0 | 6 votes |
private void dispatchRestoreInstanceState(Bundle state) { SparseArray<Parcelable> presenterStates = state.getSparseParcelableArray(PRESENTER_KEY); if (presenterStates == null || mPresenters.isEmpty()) return; for (WeakReference<MenuPresenter> ref : mPresenters) { final MenuPresenter presenter = ref.get(); if (presenter == null) { mPresenters.remove(ref); } else { final int id = presenter.getId(); if (id > 0) { Parcelable parcel = presenterStates.get(id); if (parcel != null) { presenter.onRestoreInstanceState(parcel); } } } } }
Example 3
Source File: HeaderView.java From HeaderView with MIT License | 6 votes |
@Override protected void onRestoreInstanceState(Parcelable state) { Log.d(TAG, "onRestoreInstanceState"); if (state instanceof Bundle) { Bundle bundle = (Bundle) state; state = bundle.getParcelable("superState"); //RESTORE CUSTOM VALUES profileSparseArray = bundle.getSparseParcelableArray(PROFILE_LIST) == null ? new SparseArray<>() : bundle.getSparseParcelableArray(PROFILE_LIST); populateAvatar(); } if (hvFragmentManager != null) { ProfileChooserFragment profileChooserFragment = (ProfileChooserFragment) hvFragmentManager.findFragmentByTag(ProfileChooserFragment.FRAGMENT_TAG); if (profileChooserFragment != null) { profileChooserFragment.setCallback(HeaderView.this); profileChooserFragment.updateTypeface(typeface); } } super.onRestoreInstanceState(state); }
Example 4
Source File: CustomTabsIntent.java From custom-tabs-client with Apache License 2.0 | 6 votes |
/** * Retrieves the instance of {@link CustomTabColorSchemeParams} from an Intent for a given * color scheme. Uses values passed directly into {@link CustomTabsIntent.Builder} (e.g. via * {@link Builder#setToolbarColor}) as defaults. * * @param intent Intent to retrieve the color scheme parameters from. * @param colorScheme A constant representing a color scheme. Should not be * {@link #COLOR_SCHEME_SYSTEM}. * @return An instance of {@link CustomTabColorSchemeParams} with retrieved parameters. */ @NonNull public static CustomTabColorSchemeParams getColorSchemeParams(@NonNull Intent intent, @ColorScheme int colorScheme) { if (colorScheme < 0 || colorScheme > COLOR_SCHEME_MAX || colorScheme == COLOR_SCHEME_SYSTEM) { throw new IllegalArgumentException("Invalid colorScheme: " + colorScheme); } Bundle extras = intent.getExtras(); if (extras == null) { return CustomTabColorSchemeParams.fromBundle(null); } CustomTabColorSchemeParams defaults = CustomTabColorSchemeParams.fromBundle(extras); SparseArray<Bundle> paramBundles = extras.getSparseParcelableArray( EXTRA_COLOR_SCHEME_PARAMS); if (paramBundles != null) { Bundle bundleForScheme = paramBundles.get(colorScheme); if (bundleForScheme != null) { return CustomTabColorSchemeParams.fromBundle(bundleForScheme) .withDefaults(defaults); } } return defaults; }
Example 5
Source File: MenuBuilder.java From android-apps with MIT License | 6 votes |
private void dispatchRestoreInstanceState(Bundle state) { SparseArray<Parcelable> presenterStates = state.getSparseParcelableArray(PRESENTER_KEY); if (presenterStates == null || mPresenters.isEmpty()) return; for (WeakReference<MenuPresenter> ref : mPresenters) { final MenuPresenter presenter = ref.get(); if (presenter == null) { mPresenters.remove(ref); } else { final int id = presenter.getId(); if (id > 0) { Parcelable parcel = presenterStates.get(id); if (parcel != null) { presenter.onRestoreInstanceState(parcel); } } } } }
Example 6
Source File: MenuBuilder.java From CSipSimple with GNU General Public License v3.0 | 6 votes |
private void dispatchRestoreInstanceState(Bundle state) { SparseArray<Parcelable> presenterStates = state.getSparseParcelableArray(PRESENTER_KEY); if (presenterStates == null || mPresenters.isEmpty()) return; for (WeakReference<MenuPresenter> ref : mPresenters) { final MenuPresenter presenter = ref.get(); if (presenter == null) { mPresenters.remove(ref); } else { final int id = presenter.getId(); if (id > 0) { Parcelable parcel = presenterStates.get(id); if (parcel != null) { presenter.onRestoreInstanceState(parcel); } } } } }
Example 7
Source File: BaseScene.java From EhViewer with Apache License 2.0 | 6 votes |
public final View createDrawerView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { drawerView = onCreateDrawerView(inflater, container, savedInstanceState); if (drawerView != null) { SparseArray<Parcelable> saved = drawerViewState; if (saved == null && savedInstanceState != null) { saved = savedInstanceState.getSparseParcelableArray(KEY_DRAWER_VIEW_STATE); } if (saved != null) { drawerView.restoreHierarchyState(saved); } } return drawerView; }
Example 8
Source File: NavigationMenuPresenter.java From material-components-android with Apache License 2.0 | 6 votes |
@Override public void onRestoreInstanceState(final Parcelable parcelable) { if (parcelable instanceof Bundle) { Bundle state = (Bundle) parcelable; SparseArray<Parcelable> hierarchy = state.getSparseParcelableArray(STATE_HIERARCHY); if (hierarchy != null) { menuView.restoreHierarchyState(hierarchy); } Bundle adapterState = state.getBundle(STATE_ADAPTER); if (adapterState != null) { adapter.restoreInstanceState(adapterState); } SparseArray<Parcelable> header = state.getSparseParcelableArray(STATE_HEADER); if (header != null) { headerLayout.restoreHierarchyState(header); } } }
Example 9
Source File: RecyclerPagerAdapter.java From recycler-pager-adapter with Apache License 2.0 | 5 votes |
private void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; SparseArray<Parcelable> ss = bundle.containsKey(STATE) ? bundle.getSparseParcelableArray(STATE) : null; if (ss != null) { itemView.restoreHierarchyState(ss); } } }
Example 10
Source File: State.java From flow with Apache License 2.0 | 5 votes |
@NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { Object key = parceler.toKey(savedState.getParcelable(KEY)); State state = new State(key); int[] viewIds = checkNotNull(savedState.getIntArray(VIEW_STATE_IDS), "Null view state ids?"); for (int viewId : viewIds) { SparseArray<Parcelable> viewState = savedState.getSparseParcelableArray(VIEW_STATE_PREFIX + viewId); if (viewState != null) { state.viewStateById.put(viewId, viewState); } } state.bundle = savedState.getBundle(BUNDLE); return state; }
Example 11
Source File: History.java From Mortar-architect with MIT License | 5 votes |
private static Entry fromBundle(Bundle bundle, StackableParceler parceler) { StackablePath path = parceler.unwrap(bundle.getParcelable(PATH_KEY)); // new entry with new scope instance, but preserving previous scope name Entry entry = new Entry(bundle.getString(SCOPE_KEY), path, bundle.getInt(NAV_TYPE_KEY)); entry.state = bundle.getSparseParcelableArray(STATE_KEY); return entry; }
Example 12
Source File: MenuBuilder.java From zhangshangwuda with Apache License 2.0 | 5 votes |
public void restoreActionViewStates(Bundle states) { if (states == null) { return; } SparseArray<Parcelable> viewStates = states.getSparseParcelableArray( getActionViewStatesKey()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && viewStates == null) { //Fixes Issue #652 with sdk <= 2.3.6 return; } final int itemCount = size(); for (int i = 0; i < itemCount; i++) { final MenuItem item = getItem(i); final View v = item.getActionView(); if (v != null && v.getId() != View.NO_ID) { v.restoreHierarchyState(viewStates); } if (item.hasSubMenu()) { final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); subMenu.restoreActionViewStates(states); } } final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID); if (expandedId > 0) { MenuItem itemToExpand = findItem(expandedId); if (itemToExpand != null) { itemToExpand.expandActionView(); } } }
Example 13
Source File: State.java From flowless with Apache License 2.0 | 5 votes |
@NonNull static State fromBundle(@NonNull Bundle savedState, @NonNull KeyParceler parceler) { Object key = parceler.toKey(savedState.getParcelable("KEY")); State state = new State(key); state.viewState = savedState.getSparseParcelableArray("VIEW_STATE"); state.bundle = savedState.getBundle("BUNDLE"); return state; }
Example 14
Source File: AutoValue_TestClassBundled.java From auto-value-bundle with MIT License | 5 votes |
public static TestClassBundled unbundle(Bundle bundle, Gson gson) { return new AutoValue_TestClassBundled( bundle, bundle.getByte("some_byte"), bundle.getBoolean("some_boolean"), bundle.getShort("some_short"), bundle.getInt("some_int"), bundle.getLong("some_long"), bundle.getChar("some_char"), bundle.getFloat("some_float"), bundle.getDouble("some_double"), bundle.getString("some_string"), bundle.getCharSequence("some_char_sequence"), bundle.getParcelable("some_parcelable"), bundle.getParcelableArrayList("some_parcelable_array_list"), bundle.getSparseParcelableArray("some_parcelable_sparse_array"), bundle.getSerializable("some_serializable"), bundle.getIntegerArrayList("some_integer_array_list"), bundle.getStringArrayList("some_string_array_list"), bundle.getCharSequenceArrayList("some_char_sequence_array_list"), bundle.getByteArray("some_byte_array"), bundle.getShortArray("some_short_array"), bundle.getCharArray("some_char_array"), bundle.getFloatArray("some_float_array"), gson.fromJson(bundle.getString("some_unknown_object"), new com.google.common.reflect.TypeToken<UnknownObject>(){}.getType()), gson.fromJson(bundle.getString("some_unknown_object_list"), new com.google.common.reflect.TypeToken<ArrayList<UnknownObject>>(){}.getType()), gson.fromJson(bundle.getString("test_enum"), new com.google.common.reflect.TypeToken<TestEnum>(){}.getType())); }
Example 15
Source File: ContentRecyclerAdapter.java From ChromeLikeTabSwitcher with Apache License 2.0 | 5 votes |
@Override public final void restoreInstanceState(@Nullable final Bundle savedInstanceState) { if (savedInstanceState != null) { savedInstanceStates = savedInstanceState.getSparseParcelableArray(SAVED_INSTANCE_STATES_EXTRA); } }
Example 16
Source File: MenuBuilder.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
public void restoreActionViewStates(Bundle states) { if (states == null) { return; } SparseArray<Parcelable> viewStates = states.getSparseParcelableArray( getActionViewStatesKey()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && viewStates == null) { //Fixes Issue #652 with sdk <= 2.3.6 return; } final int itemCount = size(); for (int i = 0; i < itemCount; i++) { final MenuItem item = getItem(i); final View v = item.getActionView(); if (v != null && v.getId() != View.NO_ID) { v.restoreHierarchyState(viewStates); } if (item.hasSubMenu()) { final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); subMenu.restoreActionViewStates(states); } } final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID); if (expandedId > 0) { MenuItem itemToExpand = findItem(expandedId); if (itemToExpand != null) { itemToExpand.expandActionView(); } } }
Example 17
Source File: RecyclingPagerAdapter.java From photo-viewer with Apache License 2.0 | 5 votes |
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state instanceof Bundle) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader); SparseArray<Parcelable> ss = bundle.containsKey(STATE) ? bundle.getSparseParcelableArray(STATE) : null; mSavedStates = ss != null ? ss : new SparseArray<Parcelable>(); } super.restoreState(state, loader); }
Example 18
Source File: SwipeOpenItemTouchHelper.java From SwipeOpenItemTouchHelper with Apache License 2.0 | 4 votes |
public void restoreInstanceState(Bundle savedInstanceState) { openedPositions = savedInstanceState.getSparseParcelableArray(OPENED_STATES); if (openedPositions == null) { openedPositions = new SparseArray<>(); } }
Example 19
Source File: BackstackFrame.java From fragnums with Apache License 2.0 | 4 votes |
@Override public BackstackFrame createFromParcel(Parcel source) { Screen screen = Screen.values()[source.readInt()]; Bundle bundle = source.readBundle(); SparseArray<Parcelable> viewState = bundle.getSparseParcelableArray("viewState"); return new BackstackFrame(screen, viewState); }
Example 20
Source File: Screen.java From magellan with Apache License 2.0 | 4 votes |
final void restore(Bundle savedInstanceState) { if (viewState == null && savedInstanceState != null) { viewState = savedInstanceState.getSparseParcelableArray(VIEW_STATE + hashCode()); } }