当前位置: 首页>>代码示例>>Java>>正文


Java Bundle.size方法代码示例

本文整理汇总了Java中android.os.Bundle.size方法的典型用法代码示例。如果您正苦于以下问题:Java Bundle.size方法的具体用法?Java Bundle.size怎么用?Java Bundle.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.Bundle的用法示例。


在下文中一共展示了Bundle.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getChangePayload

import android.os.Bundle; //导入方法依赖的package包/类
public static Object getChangePayload(User oldUser, User newUser) {
  Bundle bundle = new Bundle();
  if (!TextUtils.equals(oldUser.getAvatar(), newUser.getAvatar())) {
    bundle.putString(KEY_AVATAR, newUser.getAvatar());
  }
  if (!TextUtils.equals(oldUser.getName(), newUser.getName())) {
    bundle.putString(KEY_NAME, newUser.getName());
  }
  if (!TextUtils.equals(oldUser.getDesc(), newUser.getDesc())) {
    bundle.putString(KEY_DESC, newUser.getDesc());
  }
  if (bundle.size() == 0) {
    return null;
  }
  Timber.d("getChangePayload | size: %d", bundle.size());
  return bundle;
}
 
开发者ID:tranngoclam,项目名称:fast-list,代码行数:18,代码来源:User.java

示例2: PersistableBundle

import android.os.Bundle; //导入方法依赖的package包/类
public PersistableBundle(Bundle bundle) {
    map = new HashMap<>(bundle.size());
    for (String key : bundle.keySet()) {
        Object value = bundle.get(key);
        if (value == null || value instanceof String || value instanceof Integer || value instanceof Long
                || value instanceof Double || value instanceof Boolean || value instanceof String[]
                || value instanceof int[] || value instanceof long[] || value instanceof double[]
                || value instanceof boolean[]) {
            map.put(key, value);
        } else if (value instanceof Bundle) {
            map.put(key, new PersistableBundle((Bundle) value));
        } else {
            throw new IllegalArgumentException("Unsupported value type key=" + key + " value=" + value);
        }
    }
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:17,代码来源:PersistableBundle.java

示例3: encodePostBody

import android.os.Bundle; //导入方法依赖的package包/类
public static String encodePostBody(Bundle bundle, String str) {
    if (bundle == null) {
        return "";
    }
    StringBuilder stringBuilder = new StringBuilder();
    int size = bundle.size();
    int i = -1;
    for (String str2 : bundle.keySet()) {
        int i2 = i + 1;
        Object obj = bundle.get(str2);
        if (obj instanceof String) {
            stringBuilder.append("Content-Disposition: form-data; name=\"" + str2 + "\"" + "\r\n" + "\r\n" + ((String) obj));
            if (i2 < size - 1) {
                stringBuilder.append("\r\n--" + str + "\r\n");
            }
            i = i2;
        } else {
            i = i2;
        }
    }
    return stringBuilder.toString();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:HttpUtils.java

示例4: getChangePayload

import android.os.Bundle; //导入方法依赖的package包/类
@Nullable
@Override
public Object getChangePayload(int oldItemPosition, int newItemPosition) {
    DownloadInfo newDownload = mNewList.get(newItemPosition);
    DownloadInfo oldDownload = mOldList.get(oldItemPosition);
    Bundle diffBundle = new Bundle();
    if (newDownload.getProgressPercent() != oldDownload.getProgressPercent()) {
        diffBundle.putInt(KEY_PROGRESS_PERCENT_FROM, oldDownload.getProgressPercent());
        diffBundle.putInt(KEY_PROGRESS_PERCENT_TO, newDownload.getProgressPercent());
    }
    if (newDownload.bytesDownloadedSoFar != oldDownload.bytesDownloadedSoFar) {
        diffBundle.putLong(KEY_DOWNLOADED_BYTES, newDownload.bytesDownloadedSoFar);
    }
    if (newDownload.status != oldDownload.status) {
        diffBundle.putInt(KEY_STATUS_RES_ID, newDownload.getStatusTextResId());
        if (newDownload.reason != oldDownload.reason) {
            diffBundle.putInt(KEY_REASON_RES_ID, newDownload.getStatusTextResId());
        }
    }

    if (diffBundle.size() == 0) return null;
    return diffBundle;
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:24,代码来源:DownloadInfo.java

示例5: valueSizes

import android.os.Bundle; //导入方法依赖的package包/类
/**
 * Measure the sizes of all the values in a typed {@link Bundle} when written to a
 * {@link Parcel}. Returns a map from keys to the sizes, in bytes, of the associated values in
 * the Bundle.
 *
 * @param bundle to measure
 * @return a map from keys to value sizes in bytes
 */
public static Map<String, Integer> valueSizes(@NonNull Bundle bundle) {
    Map<String, Integer> result = new HashMap<>(bundle.size());
    // We measure the size of each value by measuring the total size of the bundle before and
    // after removing that value and calculating the difference. We make a copy of the original
    // bundle so we can put all the original values back at the end. It's not possible to
    // carry out the measurements on the copy because of the way Android parcelables work
    // under the hood where certain objects are actually stored as references.
    Bundle copy = new Bundle(bundle);
    try {
        int bundleSize = sizeAsParcel(bundle);
        // Iterate over copy's keys because we're removing those of the original bundle
        for (String key : copy.keySet()) {
            bundle.remove(key);
            int newBundleSize = sizeAsParcel(bundle);
            int valueSize = bundleSize - newBundleSize;
            result.put(key, valueSize);
            bundleSize = newBundleSize;
        }
        return result;
    } finally {
        // Put everything back into original bundle
        bundle.putAll(copy);
    }
}
 
开发者ID:guardian,项目名称:toolargetool,代码行数:33,代码来源:TooLargeTool.java

示例6: getChangePayload

import android.os.Bundle; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Nullable
@Override
public Object getChangePayload(@IntRange(from = 0) final int oldItemPosition,
                               @IntRange(from = 0) final int newItemPosition) {
    final IGenericRecyclerViewLayout oldItem = mOldList.get(oldItemPosition);
    final IGenericRecyclerViewLayout newItem = mNewList.get(newItemPosition);
    final Bundle diffBundle = new Bundle();

    if (!newItem.getTag().equals(oldItem.getTag())) {
        diffBundle.putSerializable(GenericPayload.UPDATE_ITEM, newItem);
    }

    if (diffBundle.size() == 0) {
        return null;
    }

    return diffBundle;
}
 
开发者ID:Simdea,项目名称:gmlrva,代码行数:20,代码来源:GmlrvaDiffCallback.java

示例7: encodePostBody

import android.os.Bundle; //导入方法依赖的package包/类
public static String encodePostBody(Bundle bundle, String str) {
    if (bundle == null) {
        return "";
    }
    StringBuilder stringBuilder = new StringBuilder();
    int size = bundle.size();
    int i = -1;
    for (String str2 : bundle.keySet()) {
        int i2 = i + 1;
        Object obj = bundle.get(str2);
        if (obj instanceof String) {
            stringBuilder.append("Content-Disposition: form-data; name=\"" + str2 + com
                    .alipay.sdk.sys.a.e + "\r\n" + "\r\n" + ((String) obj));
            if (i2 < size - 1) {
                stringBuilder.append("\r\n--" + str + "\r\n");
            }
            i = i2;
        } else {
            i = i2;
        }
    }
    return stringBuilder.toString();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:HttpUtils.java

示例8: doInvalidatePanelMenu

import android.os.Bundle; //导入方法依赖的package包/类
private void doInvalidatePanelMenu(int featureId) {
    PanelFeatureState st = getPanelState(featureId, true);
    if (st.menu != null) {
        Bundle savedActionViewStates = new Bundle();
        st.menu.saveActionViewStates(savedActionViewStates);
        if (savedActionViewStates.size() > 0) {
            st.frozenActionViewState = savedActionViewStates;
        }
        st.menu.stopDispatchingItemsChanged();
        st.menu.clear();
    }
    st.refreshMenuContent = true;
    st.refreshDecorView = true;
    if ((featureId == 108 || featureId == 0) && this.mDecorContentParent != null) {
        st = getPanelState(0, false);
        if (st != null) {
            st.isPrepared = false;
            preparePanel(st, null);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:AppCompatDelegateImplV7.java

示例9: equals

import android.os.Bundle; //导入方法依赖的package包/类
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;
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:26,代码来源:VSyncRecord.java

示例10: assertIntentEqualsActionAndExtras

import android.os.Bundle; //导入方法依赖的package包/类
private static void assertIntentEqualsActionAndExtras(Intent expected, Intent actual) {
    Assert.assertEquals(expected.getAction(), actual.getAction());

    Bundle expectedExtras = expected.getExtras();
    Bundle intentExtras = actual.getExtras();

    if (expectedExtras.size() != intentExtras.size()) {
        Assert.assertEquals(expectedExtras.size(), intentExtras.size());
    }

    for (String key : expectedExtras.keySet()) {
        Object intentExtra = intentExtras.get(key);
        Object expectedExtra = expectedExtras.get(key);
        if (intentExtra == null) {
            if (expectedExtra == null) {
                continue;
            }
            Assert.fail("found null for an expected non-null extra: " + key);
        }
        if (intentExtra instanceof long[]) {
            if (!Arrays.equals((long[]) intentExtra, (long[]) expectedExtra)) {
                Assert.assertArrayEquals("error in " + key, (long[]) expectedExtra, (long[]) intentExtra);
            }
        } else {
            if (!intentExtra.equals(expectedExtra)) {
                Assert.assertEquals("error in " + key, expectedExtra, intentExtra);
            }
        }
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:31,代码来源:PgpMessageBuilderTest.java

示例11: onCreate

import android.os.Bundle; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = getArguments();
    if (bundle != null && bundle.size() > 0) {
        initVariables(bundle);
    }
}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:9,代码来源:BaseFragment.java

示例12: initialize

import android.os.Bundle; //导入方法依赖的package包/类
public static void initialize(Bundle bundle) {
    Log.i(TAG, "Initializing");
    if ((bundle != null) && (bundle.size() > 1)) {
        if (MessagingComponent.notificationStack == null) {
            MessagingComponent.notificationStack = new ArrayList<Bundle>();
        }
        if (bundle.containsKey("google.message_id")) {
            bundle.putBoolean("tap", true);
            notificationStack.add(bundle);
        }
    }
}
 
开发者ID:jsayol,项目名称:cordova-plugin-firebase-sdk,代码行数:13,代码来源:MessagingComponent.java

示例13: upload

import android.os.Bundle; //导入方法依赖的package包/类
public static Statistic upload(Context context, String str, Bundle bundle) throws MalformedURLException, IOException, NetworkUnavailableException, HttpStatusException {
    int size;
    int i;
    byte[] byteArray;
    if (context != null) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
        if (connectivityManager != null) {
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            if (activeNetworkInfo == null || !activeNetworkInfo.isAvailable()) {
                throw new NetworkUnavailableException(NetworkUnavailableException.ERROR_INFO);
            }
        }
    }
    Bundle bundle2 = new Bundle(bundle);
    String str2 = "";
    str2 = bundle2.getString("appid_for_getting_config");
    bundle2.remove("appid_for_getting_config");
    HttpClient httpClient = HttpUtils.getHttpClient(context, str2, str);
    HttpUriRequest httpPost = new HttpPost(str);
    Bundle bundle3 = new Bundle();
    for (String str22 : bundle2.keySet()) {
        Object obj = bundle2.get(str22);
        if (obj instanceof byte[]) {
            bundle3.putByteArray(str22, (byte[]) obj);
        }
    }
    httpPost.setHeader(HttpRequest.HEADER_CONTENT_TYPE, "multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f");
    httpPost.setHeader("Connection", "Keep-Alive");
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    byteArrayOutputStream.write(getBytesUTF8("--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
    byteArrayOutputStream.write(getBytesUTF8(encodePostBody(bundle2, "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f")));
    if (!bundle3.isEmpty()) {
        size = bundle3.size();
        byteArrayOutputStream.write(getBytesUTF8("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
        i = -1;
        for (String str222 : bundle3.keySet()) {
            i++;
            byteArrayOutputStream.write(getBytesUTF8("Content-Disposition: form-data; name=\"" + str222 + "\"; filename=\"" + "value.file" + "\"" + "\r\n"));
            byteArrayOutputStream.write(getBytesUTF8("Content-Type: application/octet-stream\r\n\r\n"));
            byteArray = bundle3.getByteArray(str222);
            if (byteArray != null) {
                byteArrayOutputStream.write(byteArray);
            }
            if (i < size - 1) {
                byteArrayOutputStream.write(getBytesUTF8("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n"));
            }
        }
    }
    byteArrayOutputStream.write(getBytesUTF8("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f--\r\n"));
    byteArray = byteArrayOutputStream.toByteArray();
    i = byteArray.length + 0;
    byteArrayOutputStream.close();
    httpPost.setEntity(new ByteArrayEntity(byteArray));
    HttpResponse execute = httpClient.execute(httpPost);
    size = execute.getStatusLine().getStatusCode();
    if (size == 200) {
        return new Statistic(a(execute), i);
    }
    throw new HttpStatusException(HttpStatusException.ERROR_INFO + size);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:61,代码来源:Util.java

示例14: toMap

import android.os.Bundle; //导入方法依赖的package包/类
private HashMap<String, EpisodeTags> toMap(Bundle b) {
    int size = b != null ? b.size() : 0;
    HashMap<String, EpisodeTags> result = new HashMap<String, EpisodeTags>(size);
    if (b != null) {
        b.setClassLoader(BaseTags.class.getClassLoader());
        for (String key : b.keySet()) {
            result.put(key, b.<EpisodeTags>getParcelable(key));
        }
    }
    return result;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:12,代码来源:VideoInfoShowScraperFragment.java

示例15: toMap

import android.os.Bundle; //导入方法依赖的package包/类
private HashMap<String, EpisodeTags> toMap(Bundle b) {
    int size = (b!=null) ? b.size() : 0;
    HashMap<String, EpisodeTags> result = new HashMap<String, EpisodeTags>(size);
    if (b != null) {
        b.setClassLoader(BaseTags.class.getClassLoader());
        for (String key : b.keySet()) {
            result.put(key, b.<EpisodeTags>getParcelable(key));
        }
    }
    return result;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:12,代码来源:ManualShowScrappingSearchFragment.java


注:本文中的android.os.Bundle.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。