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

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

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

Bundle.putParcelableArray介绍

暂无

代码示例

代码示例来源:origin: androidannotations/androidannotations

public I arg(String key, Parcelable[] value) {
  args.putParcelableArray(key, value);
  return (I) this;
}

代码示例来源:origin: android-hacker/VirtualXposed

@Override
protected void onSaveInstanceState(final Bundle outState) {
  super.onSaveInstanceState(outState);
  outState.putInt(KEY_INSTANCE_STATE_PENDING_REQUEST, mPendingRequest);
  if (mPendingRequest == REQUEST_ADD_ACCOUNT) {
    outState.putParcelableArray(KEY_INSTANCE_STATE_EXISTING_ACCOUNTS, mExistingAccounts);
  }
  if (mSelectedItemIndex != SELECTED_ITEM_NONE) {
    if (mSelectedItemIndex == mAccounts.size()) {
      outState.putBoolean(KEY_INSTANCE_STATE_SELECTED_ADD_ACCOUNT, true);
    } else {
      outState.putBoolean(KEY_INSTANCE_STATE_SELECTED_ADD_ACCOUNT, false);
      outState.putString(KEY_INSTANCE_STATE_SELECTED_ACCOUNT_NAME,
          mAccounts.get(mSelectedItemIndex).name);
    }
  }
  outState.putParcelableArrayList(KEY_INSTANCE_STATE_ACCOUNT_LIST, mAccounts);
}

代码示例来源:origin: ogaclejapan/SmartTabLayout

/**
 * Inserts an array of Parcelable values into the mapping of this Bundle,
 * replacing any existing value for the given key.  Either key or value may
 * be null.
 *
 * @param key   a String, or null
 * @param value an array of Parcelable objects, or null
 */
public Bundler putParcelableArray(String key, Parcelable[] value) {
 bundle.putParcelableArray(key, value);
 return this;
}

代码示例来源:origin: ogaclejapan/SmartTabLayout

/**
 * Inserts an array of Parcelable values into the mapping of this Bundle,
 * replacing any existing value for the given key.  Either key or value may
 * be null.
 *
 * @param key   a String, or null
 * @param value an array of Parcelable objects, or null
 */
public Bundler putParcelableArray(String key, Parcelable[] value) {
 bundle.putParcelableArray(key, value);
 return this;
}

代码示例来源:origin: f2prateek/dart

/**
 * Inserts an array of Parcelable values into the mapping of the underlying Bundle, replacing any
 * existing value for the given key. Either key or value may be null.
 *
 * @param key a String, or null
 * @param value an array of Parcelable objects, or null
 * @return this bundler instance to chain method calls
 */
public Bundler put(String key, Parcelable[] value) {
 delegate.putParcelableArray(key, value);
 return this;
}

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

public BundleBuilder putParcelableArray(String key, Parcelable[] value) {
  bundle.putParcelableArray(key, value);
  return this;
}

代码示例来源:origin: rockerhieu/emojicon

@Override
public Parcelable saveState() {
  Bundle state = new Bundle();
  state.putParcelableArray("states", savedStates);
  return state;
}

代码示例来源:origin: rockerhieu/emojicon

@Override
public void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
  outState.putParcelableArray(ARG_EMOJICONS, mEmojicons);
}

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

@Override
public void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
  outState.putLong(KEY_API_UID, mApiUid);
  outState.putString(KEY_API_KEY, mApiKey);
  outState.putLong(KEY_GID, mGid);
  outState.putString(KEY_TOKEN, mToken);
  outState.putParcelableArray(KEY_COMMENTS, mComments);
}

代码示例来源:origin: Cleveroad/SlidingTutorial-Android

static Bundle getArguments(@LayoutRes int pageLayoutRes, @NonNull TransformItem[] transformItems) {
  Bundle args = new Bundle();
  args.putInt(EXTRA_PAGE_LAYOUT_RES, pageLayoutRes);
  args.putParcelableArray(EXTRA_TRANSFORM_ITEMS, ValidationUtil.checkNotNull(transformItems));
  return args;
}

代码示例来源:origin: google/cameraview

public static AspectRatioFragment newInstance(Set<AspectRatio> ratios,
    AspectRatio currentRatio) {
  final AspectRatioFragment fragment = new AspectRatioFragment();
  final Bundle args = new Bundle();
  args.putParcelableArray(ARG_ASPECT_RATIOS,
      ratios.toArray(new AspectRatio[ratios.size()]));
  args.putParcelable(ARG_CURRENT_ASPECT_RATIO, currentRatio);
  fragment.setArguments(args);
  return fragment;
}

代码示例来源:origin: TeamNewPipe/NewPipe

public static LicenseFragment newInstance(SoftwareComponent[] softwareComponents) {
  if(softwareComponents == null) {
    throw new NullPointerException("softwareComponents is null");
  }
  LicenseFragment fragment = new LicenseFragment();
  Bundle bundle = new Bundle();
  bundle.putParcelableArray(ARG_COMPONENTS, softwareComponents);
  fragment.setArguments(bundle);
  return fragment;
}

代码示例来源:origin: AppIntro/AppIntro

@Override
public Parcelable saveState() {
  Bundle state = null;
  if (mSavedState.size() > 0) {
    state = new Bundle();
    Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
    mSavedState.toArray(fss);
    state.putParcelableArray("states", fss);
  }
  for (int i = 0; i < mFragments.size(); i++) {
    Fragment f = mFragments.get(i);
    if (f != null && f.isAdded()) {
      if (state == null) {
        state = new Bundle();
      }
      String key = "f" + i;
      mFragmentManager.putFragment(state, key, f);
    }
  }
  return state;
}

代码示例来源:origin: android-hacker/VirtualXposed

public void sendResult() {
  IAccountManagerResponse response = getResponseAndClose();
  if (response != null) {
    try {
      Account[] accounts = new Account[mAccountsWithFeatures.size()];
      for (int i = 0; i < accounts.length; i++) {
        accounts[i] = mAccountsWithFeatures.get(i);
      }
      if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, getClass().getSimpleName() + " calling onResult() on response "
            + response);
      }
      Bundle result = new Bundle();
      result.putParcelableArray(AccountManager.KEY_ACCOUNTS, accounts);
      response.onResult(result);
    } catch (RemoteException e) {
      // if the caller is dead then there is no one to care about remote exceptions
      Log.v(TAG, "failure while notifying response", e);
    }
  }
}

代码示例来源:origin: aa112901/remusic

@Override
public Parcelable saveState() {
  Bundle state = null;
  if (mSavedState.size() > 0) {
    state = new Bundle();
    Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
    mSavedState.toArray(fss);
    state.putParcelableArray("states", fss);
  }
  for (int i=0; i<mFragments.size(); i++) {
    Fragment f = mFragments.get(i);
    if (f != null && f.isAdded()) {
      if (state == null) {
        state = new Bundle();
      }
      String key = "f" + i;
      mFragmentManager.putFragment(state, key, f);
    }
  }
  return state;
}

代码示例来源:origin: rockerhieu/emojicon

protected static EmojiconGridFragment newInstance(
    @Emojicon.Type int type, Emojicon[] emojicons, EmojiconRecents recents, boolean useSystemDefault) {
  EmojiconGridFragment emojiGridFragment = new EmojiconGridFragment();
  Bundle args = new Bundle();
  args.putInt(ARG_EMOJICON_TYPE, type);
  args.putParcelableArray(ARG_EMOJICONS, emojicons);
  args.putBoolean(ARG_USE_SYSTEM_DEFAULTS, useSystemDefault);
  emojiGridFragment.setArguments(args);
  emojiGridFragment.setRecents(recents);
  return emojiGridFragment;
}

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

private void onCommentGallerySuccess(GalleryComment[] result) {
  if (null == mAdapter) {
    return;
  }
  mComments = result;
  mAdapter.notifyDataSetChanged();
  Bundle re = new Bundle();
  re.putParcelableArray(KEY_COMMENTS, result);
  setResult(SceneFragment.RESULT_OK, re);
  // Remove text
  if (mEditText != null) {
    mEditText.setText("");
  }
  updateView(true);
}

代码示例来源:origin: firebase/firebase-jobdispatcher-android

private static void writeContentUriTriggerToBundle(Bundle data, ContentUriTrigger uriTrigger) {
 data.putInt(BundleProtocol.PACKED_PARAM_TRIGGER_TYPE, BundleProtocol.TRIGGER_TYPE_CONTENT_URI);
 int size = uriTrigger.getUris().size();
 int[] flagsArray = new int[size];
 Uri[] uriArray = new Uri[size];
 for (int i = 0; i < size; i++) {
  ObservedUri uri = uriTrigger.getUris().get(i);
  flagsArray[i] = uri.getFlags();
  uriArray[i] = uri.getUri();
 }
 data.putIntArray(BundleProtocol.PACKED_PARAM_CONTENT_URI_FLAGS_ARRAY, flagsArray);
 data.putParcelableArray(BundleProtocol.PACKED_PARAM_CONTENT_URI_ARRAY, uriArray);
}

代码示例来源:origin: android-hacker/VirtualXposed

@Override
public void getAccountsByFeatures(int userId, IAccountManagerResponse response, String type, String[] features) {
  if (response == null) throw new IllegalArgumentException("response is null");
  if (type == null) throw new IllegalArgumentException("accountType is null");
  AuthenticatorInfo info = getAuthenticatorInfo(type);
  if (info == null) {
    Bundle bundle = new Bundle();
    bundle.putParcelableArray(AccountManager.KEY_ACCOUNTS, new Account[0]);
    try {
      response.onResult(bundle);
    } catch (RemoteException e) {
      e.printStackTrace();
    }
    return;
  }
  if (features == null || features.length == 0) {
    Bundle bundle = new Bundle();
    bundle.putParcelableArray(AccountManager.KEY_ACCOUNTS, getAccounts(userId, type));
    try {
      response.onResult(bundle);
    } catch (RemoteException e) {
      e.printStackTrace();
    }
  } else {
    new GetAccountsByTypeAndFeatureSession(response, userId, info, features).bind();
  }
}

代码示例来源:origin: robolectric/robolectric

@Test
 public void parcelableArray() {
  Bundle innerBundle = new Bundle();
  innerBundle.putInt("value", 1);
  Parcelable[] arr = new Parcelable[] { innerBundle };
  bundle.putParcelableArray("foo", arr);

  assertThat(bundle.getParcelableArray("foo")).isEqualTo(arr);
  assertThat(bundle.getParcelableArray("bar")).isNull();
 }
}

相关文章

Bundle类方法