android.os.Bundle.getSparseParcelableArray()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中android.os.Bundle.getSparseParcelableArray()方法的一些代码示例,展示了Bundle.getSparseParcelableArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.getSparseParcelableArray()方法的具体详情如下:
包路径:android.os.Bundle
类名称:Bundle
方法名:getSparseParcelableArray

Bundle.getSparseParcelableArray介绍

暂无

代码示例

代码示例来源:origin: bluelinelabs/Conductor

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
  Bundle bundle = (Bundle)state;
  if (state != null) {
    savedPages = bundle.getSparseParcelableArray(KEY_SAVED_PAGES);
    maxPagesToStateSave = bundle.getInt(KEY_MAX_PAGES_TO_STATE_SAVE);
    savedPageHistory = bundle.getIntegerArrayList(KEY_SAVE_PAGE_HISTORY);
  }
}

代码示例来源:origin: bluelinelabs/Conductor

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
  Bundle bundle = (Bundle)state;
  if (state != null) {
    savesState = bundle.getBoolean(KEY_SAVES_STATE, false);
    savedPages = bundle.getSparseParcelableArray(KEY_SAVED_PAGES);
    int[] visiblePageIdsKeys = bundle.getIntArray(KEY_VISIBLE_PAGE_IDS_KEYS);
    String[] visiblePageIdsValues = bundle.getStringArray(KEY_VISIBLE_PAGE_IDS_VALUES);
    visiblePageIds = new SparseArray<>(visiblePageIdsKeys.length);
    for (int i = 0; i < visiblePageIdsKeys.length; i++) {
      visiblePageIds.put(visiblePageIdsKeys[i], visiblePageIdsValues[i]);
    }
  }
}

代码示例来源:origin: seven332/EhViewer

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;
}

代码示例来源:origin: bluelinelabs/Conductor

private void restoreViewState(@NonNull View view) {
  if (viewState != null) {
    view.restoreHierarchyState(viewState.getSparseParcelableArray(KEY_VIEW_STATE_HIERARCHY));
    Bundle savedViewState = viewState.getBundle(KEY_VIEW_STATE_BUNDLE);
    savedViewState.setClassLoader(getClass().getClassLoader());
    onRestoreViewState(view, savedViewState);
    restoreChildControllerHosts();
    List<LifecycleListener> listeners = new ArrayList<>(lifecycleListeners);
    for (LifecycleListener lifecycleListener : listeners) {
      lifecycleListener.onRestoreViewState(this, viewState);
    }
  }
}

代码示例来源:origin: konmik/nucleus

when(bundle.getSparseParcelableArray(anyString())).thenAnswer(get);

代码示例来源:origin: ZieIony/Carbon

public void restoreActionViewStates(Bundle states) {
  if (states == null) {
    return;
  }
  SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(
      getActionViewStatesKey());
  final int itemCount = size();
  for (int i = 0; i < itemCount; i++) {
    final android.view.MenuItem item = getItem(i);
    final View v = MenuItemCompat.getActionView(item);
    if (v != null && v.getId() != View.NO_ID) {
      v.restoreHierarchyState(viewStates);
    }
  }
  final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
  if (expandedId > 0) {
    android.view.MenuItem itemToExpand = findItem(expandedId);
    if (itemToExpand != null) {
      MenuItemCompat.expandActionView(itemToExpand);
    }
  }
}

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

@Override
public final void restoreInstanceState(@Nullable final Bundle savedInstanceState) {
  if (savedInstanceState != null) {
    savedInstanceStates =
        savedInstanceState.getSparseParcelableArray(SAVED_INSTANCE_STATES_EXTRA);
  }
}

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

savedInstanceState.getSparseParcelableArray(VIEW_HIERARCHY_STATE_EXTRA);

代码示例来源:origin: evernote/android-state

public <T extends Parcelable> SparseArray<T> getSparseParcelableArray(Bundle state, String key) {
  return state.getSparseParcelableArray(key + mBaseKey);
}

代码示例来源:origin: alex-townsend/SwipeOpenItemTouchHelper

public void restoreInstanceState(Bundle savedInstanceState) {
 openedPositions = savedInstanceState.getSparseParcelableArray(OPENED_STATES);
 if (openedPositions == null) {
  openedPositions = new SparseArray<>();
 }
}

代码示例来源:origin: wealthfront/magellan

final void restore(Bundle savedInstanceState) {
 if (viewState == null && savedInstanceState != null) {
  viewState = savedInstanceState.getSparseParcelableArray(VIEW_STATE + hashCode());
 }
}

代码示例来源:origin: alt236/Bluetooth-LE-Library---Android

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");
}

代码示例来源:origin: robotoworks/mechanoid

void restoreState(Bundle savedInstanceState) {
  if(savedInstanceState != null) {
    Bundle state = savedInstanceState.getBundle(mStateKey);
    
    if(state != null) {
      mOperations = savedInstanceState.getSparseParcelableArray("operations");
      
      if(mEnableLogging) {
        Log.d(TAG, String.format("[Restoring State]"));
      }
    }
  }
}

代码示例来源:origin: kingargyle/adt-leanback-support

public static NotificationCompatBase.Action getAction(Notification notif,
    int actionIndex, NotificationCompatBase.Action.Factory factory,
    RemoteInputCompatBase.RemoteInput.Factory remoteInputFactory) {
  Notification.Action action = notif.actions[actionIndex];
  Bundle actionExtras = null;
  SparseArray<Bundle> actionExtrasMap = notif.extras.getSparseParcelableArray(
      NotificationCompatJellybean.EXTRA_ACTION_EXTRAS);
  if (actionExtrasMap != null) {
    actionExtras = actionExtrasMap.get(actionIndex);
  }
  return NotificationCompatJellybean.readAction(factory, remoteInputFactory,
      action.icon, action.title, action.actionIntent, actionExtras);
}

代码示例来源:origin: com.willowtreeapps/oak-demos

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);
        }
      }
    }
  }
}

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

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);
        }
      }
    }
  }
}

代码示例来源:origin: jruesga/rview

@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) {
      mMenuView.restoreHierarchyState(hierarchy);
    }
    Bundle adapterState = state.getBundle(STATE_ADAPTER);
    if (adapterState != null) {
      mAdapter.restoreInstanceState(adapterState);
    }
    SparseArray<Parcelable> header = state.getSparseParcelableArray(STATE_HEADER);
    if (header != null) {
      mHeaderLayout.restoreHierarchyState(header);
    }
  }
}

代码示例来源:origin: raphaelbussa/HeaderView

@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);
    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);
}

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

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();
    }
  }
}

代码示例来源:origin: com.willowtreeapps/oak-demos

public void restoreActionViewStates(Bundle states) {
  if (states == null) {
    return;
  }
  SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(
      getActionViewStatesKey());
  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();
    }
  }
}

相关文章

Bundle类方法