本文整理汇总了Java中android.os.Bundle.putSparseParcelableArray方法的典型用法代码示例。如果您正苦于以下问题:Java Bundle.putSparseParcelableArray方法的具体用法?Java Bundle.putSparseParcelableArray怎么用?Java Bundle.putSparseParcelableArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Bundle
的用法示例。
在下文中一共展示了Bundle.putSparseParcelableArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveActionViewStates
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
}
示例2: dispatchSaveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
示例3: saveViewState
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
}
}
示例4: dispatchSaveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
}
示例5: createInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
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;
}
示例6: saveState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public Parcelable saveState() {
if (savedStateMap != null) {
Bundle state = new Bundle();
state.putSparseParcelableArray(KEY_SAVED_STATE_MAP, savedStateMap);
return state;
} else {
return null;
}
}
示例7: saveState
import android.os.Bundle; //导入方法依赖的package包/类
@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;
}
示例8: putSparseParcelableArray
import android.os.Bundle; //导入方法依赖的package包/类
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;
}
示例9: write
import android.os.Bundle; //导入方法依赖的package包/类
@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));
}
示例10: writeToParcel
import android.os.Bundle; //导入方法依赖的package包/类
@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);
}
示例11: save
import android.os.Bundle; //导入方法依赖的package包/类
final void save(Bundle outState) {
saveViewState();
if (viewState != null) {
outState.putSparseParcelableArray(VIEW_STATE + hashCode(), viewState);
}
viewState = null;
}
示例12: saveHierarchyState
import android.os.Bundle; //导入方法依赖的package包/类
public void saveHierarchyState(Bundle outState) {
SparseArray<Parcelable> viewStates = new SparseArray();
if (this.mMenuView != null) {
this.mMenuView.saveHierarchyState(viewStates);
}
outState.putSparseParcelableArray(VIEWS_TAG, viewStates);
}
示例13: onSaveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
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;
}
示例14: onSaveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
Parcelable onSaveInstanceState() {
SparseArray<Parcelable> state = new SparseArray<>();
itemView.saveHierarchyState(state);
Bundle bundle = new Bundle();
bundle.putSparseParcelableArray(STATE, state);
return bundle;
}
示例15: saveState
import android.os.Bundle; //导入方法依赖的package包/类
@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;
}