android.os.Bundle#size ( )源码实例Demo

下面列出了android.os.Bundle#size ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Ansole   文件: Term.java
private String makePathFromBundle(Bundle extras) {
    if (extras == null || extras.size() == 0) {
        return "";
    }

    String[] keys = new String[extras.size()];
    keys = extras.keySet().toArray(keys);
    Collator collator = Collator.getInstance(Locale.US);
    Arrays.sort(keys, collator);

    StringBuilder path = new StringBuilder();
    for (String key : keys) {
        String dir = extras.getString(key);
        if (dir != null && !dir.equals("")) {
            path.append(dir);
            path.append(":");
        }
    }

    return path.substring(0, path.length() - 1);
}
 
源代码2 项目: IslamicLibraryAndroid   文件: DownloadInfo.java
@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;
}
 
源代码3 项目: letv   文件: Util.java
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();
}
 
源代码4 项目: SteamGifts   文件: ListFragment.java
public static boolean equalBundles(Bundle one, Bundle two) {
    if (one == null)
        return two == null;
    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;
}
 
源代码5 项目: cwac-mediarouter   文件: RemotePlaybackClient.java
private static String bundleToString(Bundle bundle) {
    if (bundle != null) {
        bundle.size(); // force bundle to be unparcelled
        return bundle.toString();
    }
    return "null";
}
 
源代码6 项目: RecyclerTreeView   文件: TreeViewAdapter.java
private Object getChangePayload(TreeNode oldNode, TreeNode newNode) {
    Bundle diffBundle = new Bundle();
    if (newNode.isExpand() != oldNode.isExpand()) {
        diffBundle.putBoolean(KEY_IS_EXPAND, newNode.isExpand());
    }
    if (diffBundle.size() == 0)
        return null;
    return diffBundle;
}
 
源代码7 项目: MiBandDecompiled   文件: HttpUtils.java
public static String encodePostBody(Bundle bundle, String s)
{
    if (bundle == null)
    {
        return "";
    }
    StringBuilder stringbuilder = new StringBuilder();
    int i = bundle.size();
    Iterator iterator = bundle.keySet().iterator();
    int j = -1;
    while (iterator.hasNext()) 
    {
        String s1 = (String)iterator.next();
        int k = j + 1;
        Object obj = bundle.get(s1);
        if (!(obj instanceof String))
        {
            j = k;
        } else
        {
            stringbuilder.append((new StringBuilder()).append("Content-Disposition: form-data; name=\"").append(s1).append("\"").append("\r\n").append("\r\n").append((String)obj).toString());
            if (k < i - 1)
            {
                stringbuilder.append((new StringBuilder()).append("\r\n--").append(s).append("\r\n").toString());
            }
            j = k;
        }
    }
    return stringbuilder.toString();
}
 
private void buildSuppressedVisualEffectsLocked() {
    Bundle suppressedBundle = mRankingUpdate.getSuppressedVisualEffects();
    mSuppressedVisualEffects = new ArrayMap<>(suppressedBundle.size());
    for (String key: suppressedBundle.keySet()) {
        mSuppressedVisualEffects.put(key, suppressedBundle.getInt(key));
    }
}
 
private void buildImportanceExplanationLocked() {
    Bundle explanationBundle = mRankingUpdate.getImportanceExplanation();
    mImportanceExplanation = new ArrayMap<>(explanationBundle.size());
    for (String key: explanationBundle.keySet()) {
        mImportanceExplanation.put(key, explanationBundle.getString(key));
    }
}
 
源代码10 项目: android-test   文件: InstrumentationRegistryTest.java
@Test
public void testRegisterInstanceCopiesArguments() {
  Bundle setArguments = new Bundle();
  int originalSize = setArguments.size();
  InstrumentationRegistry.registerInstance(
      InstrumentationRegistry.getInstrumentation(), setArguments);
  Bundle readArguments = InstrumentationRegistry.getArguments();
  assertEquals(originalSize, readArguments.size());

  readArguments.putString("mykey", "myvalue");

  // Subsequent reads should not be affected by the local modifications.
  assertEquals(originalSize, InstrumentationRegistry.getArguments().size());
}
 
private void buildSnoozeCriteriaLocked() {
    Bundle snoozeCriteria = mRankingUpdate.getSnoozeCriteria();
    mSnoozeCriteria = new ArrayMap<>(snoozeCriteria.size());
    for (String key : snoozeCriteria.keySet()) {
        mSnoozeCriteria.put(key, snoozeCriteria.getParcelableArrayList(key));
    }
}
 
private void buildShowBadgeLocked() {
    Bundle showBadge = mRankingUpdate.getShowBadge();
    mShowBadge = new ArrayMap<>(showBadge.size());
    for (String key : showBadge.keySet()) {
        mShowBadge.put(key, showBadge.getBoolean(key));
    }
}
 
private void buildUserSentimentLocked() {
    Bundle userSentiment = mRankingUpdate.getUserSentiment();
    mUserSentiment = new ArrayMap<>(userSentiment.size());
    for (String key : userSentiment.keySet()) {
        mUserSentiment.put(key, userSentiment.getInt(key));
    }
}
 
源代码14 项目: XMVP   文件: XBaseFragment.java
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    onBeforeCreateCircle();
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        onBundleHandle(savedInstanceState);
    }

    Bundle bundle = getArguments();
    if (bundle != null && bundle.size() > 0) {
        onArgumentsHandle(bundle);
    }
}
 
源代码15 项目: android-test   文件: InstrumentationRegistryTest.java
@Test
public void testGetArgumentsReturnsIndependentCopies() {
  Bundle readArguments = InstrumentationRegistry.getArguments();
  int originalSize = readArguments.size();

  readArguments.putString("mykey", "myvalue");

  assertThat(originalSize, lessThan(readArguments.size()));
  // Subsequent reads should not be affected by the local modifications.
  assertEquals(originalSize, InstrumentationRegistry.getArguments().size());
}
 
源代码16 项目: unity-ads-android   文件: WebRequestRunnable.java
private Map<String, List<String>> getResponseHeaders(Bundle resultData) {
	Map<String, List<String>> responseHeaders = null;
	if (resultData.size() > 0) {
		responseHeaders = new HashMap<>();
		for (String k : resultData.keySet()) {
			String[] tmpAr = resultData.getStringArray(k);
			if (tmpAr != null) {
				responseHeaders.put(k, new ArrayList<>(Arrays.asList(tmpAr)));
			}
		}
	}
	return responseHeaders;
}
 
源代码17 项目: mobile-sdk-android   文件: AdMobNativeAdResponse.java
private void loadAssets() {
    nativeElements.put(NATIVE_ELEMENT_OBJECT, nativeAd);
    if (nativeAd.getHeadline() != null) {
        title = nativeAd.getHeadline().toString();
    }
    if (nativeAd.getBody() != null) {
        description = nativeAd.getBody().toString();
    }
    if (nativeAd.getCallToAction() != null) {
        callToAction = nativeAd.getCallToAction().toString();
    }
    if (nativeAd.getIcon() != null) {
        NativeAd.Image iconImage = nativeAd.getIcon();
        if (iconImage.getUri() != null) {
            iconUrl = iconImage.getUri().toString();
        }
    }
    if(nativeAd.getImages() !=null) {
        List<NativeAd.Image> images = nativeAd.getImages();
        if (images != null && images.size() > 0) {
            NativeAd.Image image = images.get(0);
            if (image.getUri() != null) {
                imageUrl = image.getUri().toString();
            }
        }
    }
    if (nativeAd.getStarRating() != null && nativeAd.getStarRating() > 0) {
        rating = new Rating(nativeAd.getStarRating(), 5.0);
    }
    if (nativeAd.getStore() != null) {
        nativeElements.put(AdMobNativeSettings.NATIVE_ELEMENT_STORE_KEY, nativeAd.getStore().toString());
    }
    if (nativeAd.getPrice() != null) {
        nativeElements.put(AdMobNativeSettings.NATIVE_ELEMENT_PRICE_KEY, nativeAd.getPrice());
    }
    if (nativeAd.getAdvertiser() != null) {
        nativeElements.put(AdMobNativeSettings.NATIVE_ELEMENT_ADVERTISER_KEY, nativeAd.getAdvertiser().toString());
    }
    Bundle bundle = nativeAd.getExtras();
    if (bundle != null && bundle.size() > 0) {
        for (String key : bundle.keySet()) {
            nativeElements.put(key, bundle.get(key));
        }
    }
}
 
源代码18 项目: shinny-futures-android   文件: OrderDiffCallback.java
@Nullable
@Override
public Object getChangePayload(int oldItemPosition, int newItemPosition) {
    Bundle bundle = new Bundle();

    try {
        String volume_origin_old = mOldData.get(oldItemPosition).getVolume_orign();
        String volume_left_old = mOldData.get(oldItemPosition).getVolume_left();
        String status_old;
        if (STATUS_ALIVE.equals(mOldData.get(oldItemPosition).getStatus()))
            status_old = STATUS_ALIVE_ZN;
        else {
            if (Integer.parseInt(volume_left_old) == 0) status_old = STATUS_FINISHED_ZN;
            else status_old = STATUS_CANCELED_ZN;
        }

        String volume_origin_new = mNewData.get(newItemPosition).getVolume_orign();
        String volume_left_new = mNewData.get(newItemPosition).getVolume_left();
        String status_new;
        if (STATUS_ALIVE.equals(mNewData.get(newItemPosition).getStatus()))
            status_new = STATUS_ALIVE_ZN;
        else {
            if (Integer.parseInt(volume_left_new) == 0) status_new = STATUS_FINISHED_ZN;
            else status_new = STATUS_CANCELED_ZN;
        }

        if (!status_old.equals(status_new))
            bundle.putString("status", status_new);

        String volume_trade_old = MathUtils.subtract(volume_origin_old, volume_left_old) + "/" + volume_origin_old;
        String volume_trade_new = MathUtils.subtract(volume_origin_new, volume_left_new) + "/" + volume_origin_new;
        if (!volume_trade_old.equals(volume_trade_new))
            bundle.putString("volume_trade", volume_trade_new);

        if (bundle.size() == 0) {
            return null;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return bundle;
}
 
@Override
public void startSync(ISyncContext syncContext, String authority, Account account,
        Bundle extras) {
    if (ENABLE_LOG) {
        if (extras != null) {
            extras.size(); // Unparcel so its toString() will show the contents.
        }
        Log.d(TAG, "startSync() start " + authority + " " + account + " " + extras);
    }
    try {
        final SyncContext syncContextClient = new SyncContext(syncContext);

        boolean alreadyInProgress;
        // synchronize to make sure that mSyncThreads doesn't change between when we
        // check it and when we use it
        final Account threadsKey = toSyncKey(account);
        synchronized (mSyncThreadLock) {
            if (!mSyncThreads.containsKey(threadsKey)) {
                if (mAutoInitialize
                        && extras != null
                        && extras.getBoolean(
                                ContentResolver.SYNC_EXTRAS_INITIALIZE, false)) {
                    try {
                        if (ContentResolver.getIsSyncable(account, authority) < 0) {
                            ContentResolver.setIsSyncable(account, authority, 1);
                        }
                    } finally {
                        syncContextClient.onFinished(new SyncResult());
                    }
                    return;
                }
                SyncThread syncThread = new SyncThread(
                        "SyncAdapterThread-" + mNumSyncStarts.incrementAndGet(),
                        syncContextClient, authority, account, extras);
                mSyncThreads.put(threadsKey, syncThread);
                syncThread.start();
                alreadyInProgress = false;
            } else {
                if (ENABLE_LOG) {
                    Log.d(TAG, "  alreadyInProgress");
                }
                alreadyInProgress = true;
            }
        }

        // do this outside since we don't want to call back into the syncContext while
        // holding the synchronization lock
        if (alreadyInProgress) {
            syncContextClient.onFinished(SyncResult.ALREADY_IN_PROGRESS);
        }
    } catch (RuntimeException | Error th) {
        if (ENABLE_LOG) {
            Log.d(TAG, "startSync() caught exception", th);
        }
        throw th;
    } finally {
        if (ENABLE_LOG) {
            Log.d(TAG, "startSync() finishing");
        }
    }
}
 
源代码20 项目: MiBandDecompiled   文件: Util.java
public static Statistic upload(Context context, String s, Bundle bundle)
{
    if (context != null)
    {
        ConnectivityManager connectivitymanager = (ConnectivityManager)context.getSystemService("connectivity");
        if (connectivitymanager != null)
        {
            NetworkInfo networkinfo = connectivitymanager.getActiveNetworkInfo();
            if (networkinfo == null || !networkinfo.isAvailable())
            {
                throw new HttpUtils.NetworkUnavailableException("network unavailable");
            }
        }
    }
    Bundle bundle1 = new Bundle(bundle);
    String s1 = bundle1.getString("appid_for_getting_config");
    bundle1.remove("appid_for_getting_config");
    HttpClient httpclient = HttpUtils.getHttpClient(context, s1, s);
    HttpPost httppost = new HttpPost(s);
    Bundle bundle2 = new Bundle();
    Iterator iterator = bundle1.keySet().iterator();
    do
    {
        if (!iterator.hasNext())
        {
            break;
        }
        String s3 = (String)iterator.next();
        Object obj = bundle1.get(s3);
        if (obj instanceof byte[])
        {
            bundle2.putByteArray(s3, (byte[])(byte[])obj);
        }
    } while (true);
    httppost.setHeader("Content-Type", "multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f");
    httppost.setHeader("Connection", "Keep-Alive");
    ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
    bytearrayoutputstream.write("--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n".getBytes());
    bytearrayoutputstream.write(encodePostBody(bundle1, "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f").getBytes());
    if (!bundle2.isEmpty())
    {
        int k = bundle2.size();
        bytearrayoutputstream.write("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n".getBytes());
        Iterator iterator1 = bundle2.keySet().iterator();
        int l = -1;
        do
        {
            if (!iterator1.hasNext())
            {
                break;
            }
            String s2 = (String)iterator1.next();
            l++;
            bytearrayoutputstream.write((new StringBuilder()).append("Content-Disposition: form-data; name=\"").append(s2).append("\"; filename=\"").append("value.file").append("\"").append("\r\n").toString().getBytes());
            bytearrayoutputstream.write("Content-Type: application/octet-stream\r\n\r\n".getBytes());
            byte abyte1[] = bundle2.getByteArray(s2);
            if (abyte1 != null)
            {
                bytearrayoutputstream.write(abyte1);
            }
            if (l < k - 1)
            {
                bytearrayoutputstream.write("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f\r\n".getBytes());
            }
        } while (true);
    }
    bytearrayoutputstream.write("\r\n--3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f--\r\n".getBytes());
    byte abyte0[] = bytearrayoutputstream.toByteArray();
    int i = 0 + abyte0.length;
    bytearrayoutputstream.close();
    httppost.setEntity(new ByteArrayEntity(abyte0));
    HttpResponse httpresponse = httpclient.execute(httppost);
    int j = httpresponse.getStatusLine().getStatusCode();
    if (j == 200)
    {
        return new Statistic(a(httpresponse), i);
    } else
    {
        throw new HttpUtils.HttpStatusException((new StringBuilder()).append("http status code error:").append(j).toString());
    }
}