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

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

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

Bundle.size介绍

暂无

代码示例

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

private static boolean isBundleEqual(Bundle bundle1, Bundle bundle2) {
 if (bundle1 == null || bundle2 == null) {
  return false;
 }
 if (bundle1.size() != bundle2.size()) {
  return false;
 }
 for (String key : bundle1.keySet()) {
  if (!bundle1.get(key).equals(bundle2.get(key))) {
   return false;
  }
 }
 return true;
}

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

public static boolean equals(Bundle a, Bundle b, boolean sameSize) {
  if (a == b) {
    return true;
  }
  if (sameSize && a.size() != b.size()) {
    return false;
  }
  if (a.size() <= b.size()) {
    Bundle smaller = a;
    a = b;
    b = smaller;
  }
  for (String key : a.keySet()) {
    if (sameSize || !isIgnoredKey(key)) {
      if (!b.containsKey(key)) {
        return false;
      }
      //noinspection ConstantConditions
      if (!a.get(key).equals(b.get(key))) {
        return false;
      }
    }
  }
  return true;
}

代码示例来源:origin: square/assertj-android

public BundleAssert hasSize(int size) {
  isNotNull();
  int actualSize = actual.size();
  assertThat(actualSize) //
    .overridingErrorMessage("Expected size <%s> but was <%s>.", size, actualSize) //
    .isEqualTo(size);
  return this;
 }
}

代码示例来源:origin: stackoverflow.com

public boolean equalBundles(Bundle one, Bundle two) {
  if(one.size() != two.size())
    return false;

  Set<String> setOne = one.keySet();
  Object valueOne;
  Object valueTwo;

  for(String key : setOne) {
    valueOne = one.get(key);
    valueTwo = two.get(key);
    if(valueOne instanceof Bundle && valueTwo instanceof Bundle && 
        !equalBundles((Bundle) valueOne, (Bundle) valueTwo)) {
      return false;
    }
    else if(valueOne == null) {
      if(valueTwo != null || !two.containsKey(key))
        return false;
    }
    else if(!valueOne.equals(valueTwo))
      return false;
  }

  return true;
}

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

@Test
public void size() {
 assertThat(bundle.size()).isEqualTo(0);
 bundle.putInt("foo", 5);
 assertThat(bundle.size()).isEqualTo(1);
 bundle.putInt("bar", 5);
 assertThat(bundle.size()).isEqualTo(2);
}

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

@Test
public void clear() {
 bundle.putFloat("foo", 5f);
 bundle.clear();
 assertThat(bundle.size()).isEqualTo(0);
}

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

return map.size();
}).when(bundle).size();
doAnswer(new Answer() {
  @Override

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

@Test
@Config(minSdk = JELLY_BEAN_MR2)
public void clearUserRestrictions() {
 assertThat(userManager.getUserRestrictions().size()).isEqualTo(0);
 shadowOf(userManager)
   .setUserRestriction(Process.myUserHandle(), UserManager.ENSURE_VERIFY_APPS, true);
 assertThat(userManager.getUserRestrictions().size()).isEqualTo(1);
 shadowOf(userManager).clearUserRestrictions(Process.myUserHandle());
 assertThat(userManager.getUserRestrictions().size()).isEqualTo(0);
}

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

static void assertBundlesEqual(Bundle inExtras, Bundle outExtras) {
 if (inExtras == null || outExtras == null) {
  assertNull(inExtras);
  assertNull(outExtras);
  return;
 }
 assertEquals("getExtras().size()", inExtras.size(), outExtras.size());
 final Set<String> inKeys = inExtras.keySet();
 for (String key : inKeys) {
  assertTrue("getExtras().containsKey(\"" + key + "\")", outExtras.containsKey(key));
  assertEquals("getExtras().get(\"" + key + "\")", inExtras.get(key), outExtras.get(key));
 }
}

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

@Test
@Config(minSdk = JELLY_BEAN_MR2)
public void getUserRestrictions() {
 assertThat(userManager.getUserRestrictions().size()).isEqualTo(0);
 UserHandle userHandle = Process.myUserHandle();
 shadowOf(userManager).setUserRestriction(userHandle, UserManager.ENSURE_VERIFY_APPS, true);
 Bundle restrictions = userManager.getUserRestrictions();
 assertThat(restrictions.size()).isEqualTo(1);
 assertThat(restrictions.getBoolean(UserManager.ENSURE_VERIFY_APPS)).isTrue();
 // make sure that the bundle is not an internal state
 restrictions.putBoolean("something", true);
 restrictions = userManager.getUserRestrictions();
 assertThat(restrictions.size()).isEqualTo(1);
 shadowOf(userManager).setUserRestriction(newUserHandle(10), UserManager.DISALLOW_CAMERA, true);
 assertThat(userManager.hasUserRestriction(UserManager.DISALLOW_CAMERA)).isFalse();
}

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

@Test
@Config(minSdk = JELLY_BEAN_MR2)
public void testGetApplicationRestrictions() {
 String packageName = context.getPackageName();
 assertThat(userManager.getApplicationRestrictions(packageName).size()).isEqualTo(0);
 Bundle restrictions = new Bundle();
 restrictions.putCharSequence("test_key", "test_value");
 shadowOf(userManager).setApplicationRestrictions(packageName, restrictions);
 assertThat(
     userManager
       .getApplicationRestrictions(packageName)
       .getCharSequence("test_key")
       .toString())
   .isEqualTo("test_value");
}

代码示例来源:origin: facebook/facebook-android-sdk

private void startShare() {
  Bundle parameters = getGraphParametersForShareContent();
  if (parameters == null || parameters.size() == 0) {
    this.finishActivityWithError(
        new FacebookRequestError(0, "", "Failed to get share content"));

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

@Test
public void extras() throws Exception {
 assertNotNull(builder.build().getExtras());
 Bundle bundle = new Bundle();
 bundle.putLong("test", 1L);
 Bundle extras = builder.addExtras(bundle).build().getExtras();
 assertEquals(1, extras.size());
 assertEquals(1L, extras.getLong("test"));
}

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

/**
 * Get the number of fields in this metadata.
 *
 * @return The number of fields in the metadata.
 */
public int size() {
  return mBundle.size();
}

代码示例来源:origin: BoD/jraf-android-util

/**
 * Returns a String representation of the bundle, or {@code "null"}.
 */
public static String toString(Bundle bundle) {
  if (bundle == null) return "null";
  bundle.size(); // This call unparcels the data
  return bundle.toString();
}

代码示例来源:origin: kinecosystem/kin-ecosystem-android-sdk

public Bundle build() throws ClientException {
  if (bundle.size() < FIELD_COUNT) {
    throw ErrorUtil.getClientException(INTERNAL_INCONSISTENCY,
      new IllegalArgumentException("You must specified all the fields."));
  }
  return bundle;
}

代码示例来源:origin: com.squareup.assertj/assertj-android

public BundleAssert hasSize(int size) {
  isNotNull();
  int actualSize = actual.size();
  assertThat(actualSize) //
    .overridingErrorMessage("Expected size <%s> but was <%s>.", size, actualSize) //
    .isEqualTo(size);
  return this;
 }
}

代码示例来源:origin: xmagicj/LazyFragment

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Bundle bundle = getArguments();
  if (bundle != null && bundle.size() > 0) {
    initVariables(bundle);
  }
}

代码示例来源:origin: wirasetiawan29/Android

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  if (getArguments() != null && getArguments().size() != 0) {
    drawable = getArguments().getInt(ARG_DRAWABLE);
    title = getArguments().getString(ARG_TITLE);
    content = getArguments().getString(ARG_CONTENT);
    titleTextColor = getArguments().getInt(ARG_TITLE_TEXT_COLOR);
    contentTextColor = getArguments().getInt(ARG_CONTENT_TEXT_COLOR);
  }
}

代码示例来源:origin: libgdx/gdx-pay

@Test
  public void convertsConfigWithOneOffer() throws Exception {
    Offer offer = offerFullEditionEntitlement();

    Bundle bundle = convertProductIdsToItemIdList(singletonList(offer.getIdentifier()));

    assertEquals(1, bundle.size());
    ArrayList<String> actualList = bundle.getStringArrayList(ITEM_ID_LIST);

    ArrayList<String> expectedArrayList = new ArrayList<>(singletonList(offerFullEditionEntitlement().getIdentifier()));
    assertEquals(expectedArrayList, actualList);
  }
}

相关文章

Bundle类方法