下面列出了android.util.ArrayMap#removeAt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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();
}
}
@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();
}
}
@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();
}
}
/**
* 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;
}
}
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);
}
}
}
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);
}
}
}
/**
* 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);
}
}
}
}
/**
* 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);
}
}
}
/**
* 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;
}