Java Code Examples for android.os.Bundle.putSparseParcelableArray()

The following are Jave code examples for showing how to use putSparseParcelableArray() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CSipSimple   File: MenuBuilder.java   View Source Code Vote up 7 votes
public void saveActionViewStates(Bundle outStates) {
    SparseArray<Parcelable> viewStates = null;

    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) {
            if (viewStates == null) {
                viewStates = new SparseArray<Parcelable>();
            }
            v.saveHierarchyState(viewStates);
            if (item.isActionViewExpanded()) {
                outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId());
            }
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.saveActionViewStates(outStates);
        }
    }

    if (viewStates != null) {
        outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates);
    }
}
 
Example 2
Project: CSipSimple   File: MenuBuilder.java   View Source Code Vote up 6 votes
private void dispatchSaveInstanceState(Bundle outState) {
    if (mPresenters.isEmpty()) return;

    SparseArray<Parcelable> presenterStates = new SparseArray<Parcelable>();

    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) {
                final Parcelable state = presenter.onSaveInstanceState();
                if (state != null) {
                    presenterStates.put(id, state);
                }
            }
        }
    }

    outState.putSparseParcelableArray(PRESENTER_KEY, presenterStates);
}
 
Example 3
Project: Stage   File: Scene.java   View Source Code Vote up 6 votes
private void saveViewState(@NonNull View view) {
  viewState = new Bundle(getClass().getClassLoader());

  SparseArray<Parcelable> hierarchyState = new SparseArray<>();
  view.saveHierarchyState(hierarchyState);
  viewState.putSparseParcelableArray(KEY_VIEW_STATE_HIERARCHY, hierarchyState);

  Bundle stateBundle = new Bundle(getClass().getClassLoader());
  onSaveViewState(view, stateBundle);
  viewState.putBundle(KEY_VIEW_STATE_BUNDLE, stateBundle);

  if (!lifecycleListeners.isEmpty()) {
    for (LifecycleListener listener : new ArrayList<>(lifecycleListeners)) {
      listener.onSaveViewState(this, viewState);
    }
  }
}
 
Example 4
Project: boohee_v5.6   File: MenuBuilder.java   View Source Code Vote up 6 votes
private void dispatchSaveInstanceState(Bundle outState) {
    if (!this.mPresenters.isEmpty()) {
        SparseArray<Parcelable> presenterStates = new SparseArray();
        Iterator i$ = this.mPresenters.iterator();
        while (i$.hasNext()) {
            WeakReference<MenuPresenter> ref = (WeakReference) i$.next();
            MenuPresenter presenter = (MenuPresenter) ref.get();
            if (presenter == null) {
                this.mPresenters.remove(ref);
            } else {
                int id = presenter.getId();
                if (id > 0) {
                    Parcelable state = presenter.onSaveInstanceState();
                    if (state != null) {
                        presenterStates.put(id, state);
                    }
                }
            }
        }
        outState.putSparseParcelableArray(PRESENTER_KEY, presenterStates);
    }
}
 
Example 5
Project: boohee_v5.6   File: NavigationMenuPresenter.java   View Source Code Vote up 6 votes
public Bundle createInstanceState() {
    Bundle state = new Bundle();
    if (this.mCheckedItem != null) {
        state.putInt(STATE_CHECKED_ITEM, this.mCheckedItem.getItemId());
    }
    SparseArray<ParcelableSparseArray> actionViewStates = new SparseArray();
    Iterator i$ = this.mItems.iterator();
    while (i$.hasNext()) {
        NavigationMenuItem navigationMenuItem = (NavigationMenuItem) i$.next();
        if (navigationMenuItem instanceof NavigationMenuTextItem) {
            MenuItemImpl item = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
            View actionView = item != null ? item.getActionView() : null;
            if (actionView != null) {
                ParcelableSparseArray container = new ParcelableSparseArray();
                actionView.saveHierarchyState(container);
                actionViewStates.put(item.getItemId(), container);
            }
        }
    }
    state.putSparseParcelableArray(STATE_ACTION_VIEWS, actionViewStates);
    return state;
}
 
Example 6
Project: Stage   File: StagePagerAdapter.java   View Source Code Vote up 5 votes
@Override
public Parcelable saveState() {
  if (savedStateMap != null) {
    Bundle state = new Bundle();
    state.putSparseParcelableArray(KEY_SAVED_STATE_MAP, savedStateMap);
    return state;
  } else {
    return null;
  }
}
 
Example 7
Project: bananapeel   File: TabAdapter.java   View Source Code Vote up 5 votes
@Override
public Parcelable saveState()
{
	for(TabFragment fragment : tabFragments)
		savedStates.put(fragment.getTabId(), fragment.isAdded() ? fragmentManager.saveFragmentInstanceState(fragment) : null);
	Bundle state = new Bundle();
	state.putSparseParcelableArray("states", savedStates);
	return state;
}
 
Example 8
Project: garras   File: Bundler.java   View Source Code Vote up 5 votes
public Bundler putSparseParcelableArray(@NonNull String key, SparseArray<? extends Parcelable> value) {
    Bundle safeBundle = new Bundle();
    safeBundle.putSparseParcelableArray(key, value);
    if (isValidBundleSize(safeBundle)) {
        bundle.putSparseParcelableArray(key, value);
    }
    clearBundle(safeBundle);
    return this;
}
 
Example 9
Project: MagicBox   File: SparseParcelableArrayWriter.java   View Source Code Vote up 5 votes
@Override
public void write(Bundle bundle, Object to, StateField field) throws IllegalAccessException {
    Field propertyField = field.getField();
    propertyField.setAccessible(true);
    bundle.putSparseParcelableArray(field.getBundleKey(), (SparseArray<? extends Parcelable>) propertyField.get(to));

}
 
Example 10
Project: AndroidMuseumBleManager   File: AdRecordStore.java   View Source Code Vote up 5 votes
@Override
public void writeToParcel(final Parcel parcel, final int arg1) {
    final Bundle b = new Bundle();
    b.putString("local_name_complete", mLocalNameComplete);
    b.putString("local_name_short", mLocalNameShort);
    b.putSparseParcelableArray("records_array", mAdRecords);

    parcel.writeBundle(b);
}
 
Example 11
Project: magellan   File: Screen.java   View Source Code Vote up 5 votes
final void save(Bundle outState) {
  saveViewState();
  if (viewState != null) {
    outState.putSparseParcelableArray(VIEW_STATE + hashCode(), viewState);
  }
  viewState = null;
}
 
Example 12
Project: boohee_v5.6   File: ListMenuPresenter.java   View Source Code Vote up 5 votes
public void saveHierarchyState(Bundle outState) {
    SparseArray<Parcelable> viewStates = new SparseArray();
    if (this.mMenuView != null) {
        this.mMenuView.saveHierarchyState(viewStates);
    }
    outState.putSparseParcelableArray(VIEWS_TAG, viewStates);
}
 
Example 13
Project: boohee_v5.6   File: NavigationMenuPresenter.java   View Source Code Vote up 5 votes
public Parcelable onSaveInstanceState() {
    Bundle state = new Bundle();
    if (this.mMenuView != null) {
        SparseArray<Parcelable> hierarchy = new SparseArray();
        this.mMenuView.saveHierarchyState(hierarchy);
        state.putSparseParcelableArray("android:menu:list", hierarchy);
    }
    if (this.mAdapter != null) {
        state.putBundle(STATE_ADAPTER, this.mAdapter.createInstanceState());
    }
    return state;
}
 
Example 14
Project: imageviewer   File: ViewHolder.java   View Source Code Vote up 5 votes
Parcelable onSaveInstanceState() {
    SparseArray<Parcelable> state = new SparseArray<>();
    itemView.saveHierarchyState(state);
    Bundle bundle = new Bundle();
    bundle.putSparseParcelableArray(STATE, state);
    return bundle;
}
 
Example 15
Project: imageviewer   File: RecyclingPagerAdapter.java   View Source Code Vote up 5 votes
@Override
public Parcelable saveState() {
    Bundle bundle = new Bundle();
    for (ViewHolder viewHolder : getAttachedViewHolders()) {
        mSavedStates.put(getItemId(viewHolder.mPosition), viewHolder.onSaveInstanceState());
    }
    bundle.putSparseParcelableArray(STATE, mSavedStates);
    return bundle;
}
 
Example 16
Project: GitHub   File: Injector.java   View Source Code Vote up 4 votes
public void putSparseParcelableArray(Bundle state, String key, SparseArray<? extends Parcelable> x) {
    state.putSparseParcelableArray(key + baseKey, x);
}
 
Example 17
Project: android-state   File: InjectionHelper.java   View Source Code Vote up 4 votes
public void putSparseParcelableArray(Bundle state, String key, SparseArray<? extends Parcelable> x) {
    state.putSparseParcelableArray(key + mBaseKey, x);
}
 
Example 18
Project: ChromeLikeTabSwitcher   File: ContentRecyclerAdapter.java   View Source Code Vote up 4 votes
@Override
public final void saveInstanceState(@NonNull final Bundle outState) {
    outState.putSparseParcelableArray(SAVED_INSTANCE_STATES_EXTRA, savedInstanceStates);
}
 
Example 19
Project: ChromeLikeTabSwitcher   File: TabSwitcherDecorator.java   View Source Code Vote up 3 votes
/**
 * The method, which is invoked by a {@link TabSwitcher} to save the current state of a tab. It
 * initializes the view holder pattern, which is provided by the decorator and then delegates
 * the method call to the decorator's custom implementation of the method
 * <code>onSaveInstanceState(...):void</code>.
 *
 * @param view
 *         The view, which is used to visualize the tab, as an instance of the class {@link
 *         View}
 * @param tab
 *         The tab, whose state should be saved, as an instance of the class {@link Tab}. The
 *         tab may not be null
 * @param index
 *         The index of the tab, whose state should be saved, as an {@link Integer} value
 * @return The bundle, which has been used to save the state, as an instance of the class {@link
 * Bundle}. The bundle may not be null
 */
@NonNull
public final Bundle saveInstanceState(@NonNull final View view, @NonNull final Tab tab,
                                      final int index) {
    setCurrentParentView(view);
    int viewType = getViewType(tab, index);
    Bundle outState = new Bundle();
    SparseArray<Parcelable> viewStates = new SparseArray<>();
    view.saveHierarchyState(viewStates);
    outState.putSparseParcelableArray(VIEW_HIERARCHY_STATE_EXTRA, viewStates);
    onSaveInstanceState(view, tab, index, viewType, outState);
    return outState;
}
 
Example 20
Project: NeoTerm   File: TabSwitcherDecorator.java   View Source Code Vote up 3 votes
/**
 * The method, which is invoked by a {@link TabSwitcher} to save the current state of a tab. It
 * initializes the view holder pattern, which is provided by the decorator and then delegates
 * the method call to the decorator's custom implementation of the method
 * <code>onSaveInstanceState(...):void</code>.
 *
 * @param view
 *         The view, which is used to visualize the tab, as an instance of the class {@link
 *         View}
 * @param tab
 *         The tab, whose state should be saved, as an instance of the class {@link Tab}. The
 *         tab may not be null
 * @param index
 *         The index of the tab, whose state should be saved, as an {@link Integer} value
 * @return The bundle, which has been used to save the state, as an instance of the class {@link
 * Bundle}. The bundle may not be null
 */
@NonNull
public final Bundle saveInstanceState(@NonNull final View view, @NonNull final Tab tab,
                                      final int index) {
    setCurrentParentView(view);
    int viewType = getViewType(tab, index);
    Bundle outState = new Bundle();
    SparseArray<Parcelable> viewStates = new SparseArray<>();
    view.saveHierarchyState(viewStates);
    outState.putSparseParcelableArray(VIEW_HIERARCHY_STATE_EXTRA, viewStates);
    onSaveInstanceState(view, tab, index, viewType, outState);
    return outState;
}