Java Code Examples for android.os.bundle#size()
The following examples show how to use
android.os.bundle#size() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Term.java From Ansole with GNU General Public License v2.0 | 6 votes |
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); }
Example 2
Source File: ListFragment.java From SteamGifts with MIT License | 6 votes |
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; }
Example 3
Source File: DownloadInfo.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 6 votes |
@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; }
Example 4
Source File: Util.java From letv with Apache License 2.0 | 6 votes |
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(); }
Example 5
Source File: WebRequestRunnable.java From unity-ads-android with Apache License 2.0 | 5 votes |
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; }
Example 6
Source File: InstrumentationRegistryTest.java From android-test with Apache License 2.0 | 5 votes |
@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()); }
Example 7
Source File: XBaseFragment.java From XMVP with Apache License 2.0 | 5 votes |
@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); } }
Example 8
Source File: NotificationListenerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void buildUserSentimentLocked() { Bundle userSentiment = mRankingUpdate.getUserSentiment(); mUserSentiment = new ArrayMap<>(userSentiment.size()); for (String key : userSentiment.keySet()) { mUserSentiment.put(key, userSentiment.getInt(key)); } }
Example 9
Source File: NotificationListenerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void buildShowBadgeLocked() { Bundle showBadge = mRankingUpdate.getShowBadge(); mShowBadge = new ArrayMap<>(showBadge.size()); for (String key : showBadge.keySet()) { mShowBadge.put(key, showBadge.getBoolean(key)); } }
Example 10
Source File: NotificationListenerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void buildSnoozeCriteriaLocked() { Bundle snoozeCriteria = mRankingUpdate.getSnoozeCriteria(); mSnoozeCriteria = new ArrayMap<>(snoozeCriteria.size()); for (String key : snoozeCriteria.keySet()) { mSnoozeCriteria.put(key, snoozeCriteria.getParcelableArrayList(key)); } }
Example 11
Source File: InstrumentationRegistryTest.java From android-test with Apache License 2.0 | 5 votes |
@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()); }
Example 12
Source File: NotificationListenerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void buildImportanceExplanationLocked() { Bundle explanationBundle = mRankingUpdate.getImportanceExplanation(); mImportanceExplanation = new ArrayMap<>(explanationBundle.size()); for (String key: explanationBundle.keySet()) { mImportanceExplanation.put(key, explanationBundle.getString(key)); } }
Example 13
Source File: NotificationListenerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void buildSuppressedVisualEffectsLocked() { Bundle suppressedBundle = mRankingUpdate.getSuppressedVisualEffects(); mSuppressedVisualEffects = new ArrayMap<>(suppressedBundle.size()); for (String key: suppressedBundle.keySet()) { mSuppressedVisualEffects.put(key, suppressedBundle.getInt(key)); } }
Example 14
Source File: HttpUtils.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
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(); }
Example 15
Source File: TreeViewAdapter.java From RecyclerTreeView with Apache License 2.0 | 5 votes |
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; }
Example 16
Source File: RemotePlaybackClient.java From cwac-mediarouter with Apache License 2.0 | 5 votes |
private static String bundleToString(Bundle bundle) { if (bundle != null) { bundle.size(); // force bundle to be unparcelled return bundle.toString(); } return "null"; }
Example 17
Source File: AbstractThreadedSyncAdapter.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@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"); } } }
Example 18
Source File: Util.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
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()); } }
Example 19
Source File: OrderDiffCallback.java From shinny-futures-android with GNU General Public License v3.0 | 4 votes |
@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; }
Example 20
Source File: AdMobNativeAdResponse.java From mobile-sdk-android with Apache License 2.0 | 4 votes |
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)); } } }