Java Code Examples for android.util.ArrayMap#removeAt()
The following examples show how to use
android.util.ArrayMap#removeAt() .
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: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
private void invalidateCacheLocked(int userId, String providerPackageName, Uri uri) { ArrayMap<String, ArrayMap<Pair<String, Uri>, Bundle>> userCache = mCache.get(userId); if (userCache == null) return; ArrayMap<Pair<String, Uri>, Bundle> packageCache = userCache.get(providerPackageName); if (packageCache == null) return; if (uri != null) { for (int i = 0; i < packageCache.size();) { final Pair<String, Uri> key = packageCache.keyAt(i); if (key.second != null && key.second.toString().startsWith(uri.toString())) { if (DEBUG) Slog.d(TAG, "Invalidating cache for key " + key); packageCache.removeAt(i); } else { i++; } } } else { if (DEBUG) Slog.d(TAG, "Invalidating cache for package " + providerPackageName); packageCache.clear(); } }
Example 2
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@GuardedBy("mCache") private void invalidateCacheLocked(int userId, String providerPackageName, Uri uri) { ArrayMap<String, ArrayMap<Pair<String, Uri>, Bundle>> userCache = mCache.get(userId); if (userCache == null) return; ArrayMap<Pair<String, Uri>, Bundle> packageCache = userCache.get(providerPackageName); if (packageCache == null) return; if (uri != null) { for (int i = 0; i < packageCache.size();) { final Pair<String, Uri> key = packageCache.keyAt(i); if (key.second != null && key.second.toString().startsWith(uri.toString())) { if (DEBUG) Slog.d(TAG, "Invalidating cache for key " + key); packageCache.removeAt(i); } else { i++; } } } else { if (DEBUG) Slog.d(TAG, "Invalidating cache for package " + providerPackageName); packageCache.clear(); } }
Example 3
Source File: ContentService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@GuardedBy("mCache") private void invalidateCacheLocked(int userId, String providerPackageName, Uri uri) { ArrayMap<String, ArrayMap<Pair<String, Uri>, Bundle>> userCache = mCache.get(userId); if (userCache == null) return; ArrayMap<Pair<String, Uri>, Bundle> packageCache = userCache.get(providerPackageName); if (packageCache == null) return; if (uri != null) { for (int i = 0; i < packageCache.size();) { final Pair<String, Uri> key = packageCache.keyAt(i); if (key.second != null && key.second.toString().startsWith(uri.toString())) { if (DEBUG) Slog.d(TAG, "Invalidating cache for key " + key); packageCache.removeAt(i); } else { i++; } } } else { if (DEBUG) Slog.d(TAG, "Invalidating cache for package " + providerPackageName); packageCache.clear(); } }
Example 4
Source File: ActivityTransitionCoordinator.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Iterates over the shared elements and adds them to the members in order. * Shared elements that are nested in other shared elements are placed after the * elements that they are nested in. This means that layout ordering can be done * from first to last. * * @param sharedElements The map of transition names to shared elements to set into * the member fields. */ private void setSharedElements(ArrayMap<String, View> sharedElements) { boolean isFirstRun = true; while (!sharedElements.isEmpty()) { final int numSharedElements = sharedElements.size(); for (int i = numSharedElements - 1; i >= 0; i--) { final View view = sharedElements.valueAt(i); final String name = sharedElements.keyAt(i); if (isFirstRun && (view == null || !view.isAttachedToWindow() || name == null)) { sharedElements.removeAt(i); } else if (!isNested(view, sharedElements)) { mSharedElementNames.add(name); mSharedElements.add(view); sharedElements.removeAt(i); } } isFirstRun = false; } }
Example 5
Source File: ZenModeFiltering.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private synchronized void cleanUp(ArrayMap<String, Long> calls, long now) { final int N = calls.size(); for (int i = N - 1; i >= 0; i--) { final long time = mCalls.valueAt(i); if (time > now || (now - time) > mThresholdMinutes * 1000 * 60) { calls.removeAt(i); } } }
Example 6
Source File: AppErrors.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void resetProcessCrashTimeLocked(boolean resetEntireUser, int appId, int userId) { final ArrayMap<String, SparseArray<Long>> pmap = mProcessCrashTimes.getMap(); for (int ip = pmap.size() - 1; ip >= 0; ip--) { SparseArray<Long> ba = pmap.valueAt(ip); for (int i = ba.size() - 1; i >= 0; i--) { boolean remove = false; final int entUid = ba.keyAt(i); if (!resetEntireUser) { if (userId == UserHandle.USER_ALL) { if (UserHandle.getAppId(entUid) == appId) { remove = true; } } else { if (entUid == UserHandle.getUid(userId, appId)) { remove = true; } } } else if (UserHandle.getUserId(entUid) == userId) { remove = true; } if (remove) { ba.removeAt(i); } } if (ba.size() == 0) { pmap.removeAt(ip); } } }
Example 7
Source File: Transition.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Match start/end values by View instance. Adds matched values to mStartValuesList * and mEndValuesList and removes them from unmatchedStart and unmatchedEnd. */ private void matchInstances(ArrayMap<View, TransitionValues> unmatchedStart, ArrayMap<View, TransitionValues> unmatchedEnd) { for (int i = unmatchedStart.size() - 1; i >= 0; i--) { View view = unmatchedStart.keyAt(i); if (view != null && isValidTarget(view)) { TransitionValues end = unmatchedEnd.remove(view); if (end != null && end.view != null && isValidTarget(end.view)) { TransitionValues start = unmatchedStart.removeAt(i); mStartValuesList.add(start); mEndValuesList.add(end); } } } }
Example 8
Source File: FragmentTransition.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * A utility to retain only the mappings in {@code nameOverrides} that have a value * that has a key in {@code namedViews}. This is a useful equivalent to * {@link ArrayMap#retainAll(Collection)} for values. */ private static void retainValues(ArrayMap<String, String> nameOverrides, ArrayMap<String, View> namedViews) { for (int i = nameOverrides.size() - 1; i >= 0; i--) { final String targetName = nameOverrides.valueAt(i); if (!namedViews.containsKey(targetName)) { nameOverrides.removeAt(i); } } }
Example 9
Source File: Bundle.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Filter values in Bundle to only basic types. * @hide */ public Bundle filterValues() { unparcel(); Bundle bundle = this; if (mMap != null) { ArrayMap<String, Object> map = mMap; for (int i = map.size() - 1; i >= 0; i--) { Object value = map.valueAt(i); if (PersistableBundle.isValidType(value)) { continue; } if (value instanceof Bundle) { Bundle newBundle = ((Bundle)value).filterValues(); if (newBundle != value) { if (map == mMap) { // The filter had to generate a new bundle, but we have not yet // created a new one here. Do that now. bundle = new Bundle(this); // Note the ArrayMap<> constructor is guaranteed to generate // a new object with items in the same order as the original. map = bundle.mMap; } // Replace this current entry with the new child bundle. map.setValueAt(i, newBundle); } continue; } if (value.getClass().getName().startsWith("android.")) { continue; } if (map == mMap) { // This is the first time we have had to remove something, that means we // need to switch to a new Bundle. bundle = new Bundle(this); // Note the ArrayMap<> constructor is guaranteed to generate // a new object with items in the same order as the original. map = bundle.mMap; } map.removeAt(i); } } mFlags |= FLAG_HAS_FDS_KNOWN; mFlags &= ~FLAG_HAS_FDS; return bundle; }