本文整理汇总了Java中android.os.Bundle.getSparseParcelableArray方法的典型用法代码示例。如果您正苦于以下问题:Java Bundle.getSparseParcelableArray方法的具体用法?Java Bundle.getSparseParcelableArray怎么用?Java Bundle.getSparseParcelableArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Bundle
的用法示例。
在下文中一共展示了Bundle.getSparseParcelableArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchRestoreInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
}
}
}
}
示例2: restoreState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void restoreState(Parcelable state, ClassLoader loader)
{
if(state != null)
{
Bundle bundle = (Bundle)state;
bundle.setClassLoader(loader);
SparseArray fss = bundle.getSparseParcelableArray("states");
for(TabFragment fragment : tabFragments)
{
if(curTransaction == null)
curTransaction = fragmentManager.beginTransaction();
curTransaction.remove(fragment);
}
savedStates.clear();
tabFragments.clear();
if(fss != null)
{
for(int i = 0; i < fss.size(); i++)
savedStates.put(fss.keyAt(i), (Fragment.SavedState)fss.valueAt(i));
}
}
}
示例3: restoreState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
if (state != null) {
Bundle bundle = (Bundle) state;
bundle.setClassLoader(loader);
mSavedState.clear();
mFragments.clear();
if (bundle.containsKey("states")) {
mSavedState = bundle.getSparseParcelableArray("states");
}
Iterable<String> keys = bundle.keySet();
for (String key : keys) {
if (key.startsWith("f")) {
int index = Integer.parseInt(key.substring(1));
Fragment f = mFragmentManager.getFragment(bundle, key);
if (f != null) {
f.setMenuVisibility(false);
mFragments.put(index, f);
} else {
// Log.w(TAG, "Bad fragment at key " + key);
}
}
}
}
}
示例4: dispatchRestoreInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
private void dispatchRestoreInstanceState(Bundle state) {
SparseArray<Parcelable> presenterStates = state.getSparseParcelableArray(PRESENTER_KEY);
if (presenterStates != null && !this.mPresenters.isEmpty()) {
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 parcel = (Parcelable) presenterStates.get(id);
if (parcel != null) {
presenter.onRestoreInstanceState(parcel);
}
}
}
}
}
}
示例5: restoreActionViewStates
import android.os.Bundle; //导入方法依赖的package包/类
public void restoreActionViewStates(Bundle states) {
if (states != null) {
SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(getActionViewStatesKey());
int itemCount = size();
for (int i = 0; i < itemCount; i++) {
MenuItem item = getItem(i);
View v = MenuItemCompat.getActionView(item);
if (!(v == null || v.getId() == -1)) {
v.restoreHierarchyState(viewStates);
}
if (item.hasSubMenu()) {
((SubMenuBuilder) item.getSubMenu()).restoreActionViewStates(states);
}
}
int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
if (expandedId > 0) {
MenuItem itemToExpand = findItem(expandedId);
if (itemToExpand != null) {
MenuItemCompat.expandActionView(itemToExpand);
}
}
}
}
示例6: restoreActionViewStates
import android.os.Bundle; //导入方法依赖的package包/类
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();
}
}
}
示例7: restoreInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
@Override
public final void restoreInstanceState(@Nullable final Bundle savedInstanceState) {
if (savedInstanceState != null) {
savedInstanceStates =
savedInstanceState.getSparseParcelableArray(SAVED_INSTANCE_STATES_EXTRA);
}
}
示例8: restoreInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
public void restoreInstanceState(Bundle state) {
Iterator i$;
int checkedItem = state.getInt(STATE_CHECKED_ITEM, 0);
if (checkedItem != 0) {
this.mUpdateSuspended = true;
i$ = this.mItems.iterator();
while (i$.hasNext()) {
NavigationMenuItem item = (NavigationMenuItem) i$.next();
if (item instanceof NavigationMenuTextItem) {
MenuItemImpl menuItem = ((NavigationMenuTextItem) item).getMenuItem();
if (menuItem != null && menuItem.getItemId() == checkedItem) {
setCheckedItem(menuItem);
break;
}
}
}
this.mUpdateSuspended = false;
prepareMenuItems();
}
SparseArray<ParcelableSparseArray> actionViewStates = state.getSparseParcelableArray(STATE_ACTION_VIEWS);
i$ = this.mItems.iterator();
while (i$.hasNext()) {
NavigationMenuItem navigationMenuItem = (NavigationMenuItem) i$.next();
if (navigationMenuItem instanceof NavigationMenuTextItem) {
MenuItemImpl item2 = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
View actionView = item2 != null ? item2.getActionView() : null;
if (actionView != null) {
actionView.restoreHierarchyState((SparseArray) actionViewStates.get(item2.getItemId()));
}
}
}
}
示例9: onRestoreInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
public void onRestoreInstanceState(Parcelable parcelable) {
Bundle state = (Bundle) parcelable;
SparseArray<Parcelable> hierarchy = state.getSparseParcelableArray("android:menu:list");
if (hierarchy != null) {
this.mMenuView.restoreHierarchyState(hierarchy);
}
Bundle adapterState = state.getBundle(STATE_ADAPTER);
if (adapterState != null) {
this.mAdapter.restoreInstanceState(adapterState);
}
}
示例10: unbundle
import android.os.Bundle; //导入方法依赖的package包/类
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()));
}
示例11: onRestoreInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
}
}
示例12: restoreState
import android.os.Bundle; //导入方法依赖的package包/类
@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);
}
示例13: getSparseParcelableArray
import android.os.Bundle; //导入方法依赖的package包/类
public <T extends Parcelable> SparseArray<T> getSparseParcelableArray(Bundle state, String key) {
return state.getSparseParcelableArray(key + baseKey);
}
示例14: getSparseParcelableArray
import android.os.Bundle; //导入方法依赖的package包/类
public <T extends Parcelable> SparseArray<T> getSparseParcelableArray(Bundle state, String key) {
return state.getSparseParcelableArray(key + mBaseKey);
}
示例15: AdRecordStore
import android.os.Bundle; //导入方法依赖的package包/类
public AdRecordStore(final Parcel in) {
final Bundle b = in.readBundle(getClass().getClassLoader());
mAdRecords = b.getSparseParcelableArray("records_array");
mLocalNameComplete = b.getString("local_name_complete");
mLocalNameShort = b.getString("local_name_short");
}