android.util.ArrayMap#remove ( )源码实例Demo

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

源代码1 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public boolean moveSharedPreferencesFrom(Context sourceContext, String name) {
    synchronized (ContextImpl.class) {
        final File source = sourceContext.getSharedPreferencesPath(name);
        final File target = getSharedPreferencesPath(name);

        final int res = moveFiles(source.getParentFile(), target.getParentFile(),
                source.getName());
        if (res > 0) {
            // We moved at least one file, so evict any in-memory caches for
            // either location
            final ArrayMap<File, SharedPreferencesImpl> cache =
                    getSharedPreferencesCacheLocked();
            cache.remove(source);
            cache.remove(target);
        }
        return res != -1;
    }
}
 
源代码2 项目: Neptune   文件: LayoutInflaterCompat.java
/**
 * 处理Fragment的缓存
 */
private void resetFragmentClassMap(Context context, String fname) {
    if (isSupportFragmentClass(context, fname)) {
        resetSupportFragmentClassMap(context, fname);
        return;
    }

    ArrayMap<String, Class<?>> classMap = getFragmentClassMap();
    if (classMap != null) {
        Class<?> clazz = classMap.get(fname);
        if (clazz != null && !verifyClassLoader(context, clazz)) {
            PluginDebugLog.runtimeFormatLog(TAG, "find same app fragment class name in LayoutInflater cache and remove it %s", fname);
            clazz = null;
            classMap.remove(fname);
        }
    }
}
 
源代码3 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public boolean deleteSharedPreferences(String name) {
    synchronized (ContextImpl.class) {
        final File prefs = getSharedPreferencesPath(name);
        final File prefsBackup = SharedPreferencesImpl.makeBackupFile(prefs);

        // Evict any in-memory caches
        final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
        cache.remove(prefs);

        prefs.delete();
        prefsBackup.delete();

        // We failed if files are still lingering
        return !(prefs.exists() || prefsBackup.exists());
    }
}
 
源代码4 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public boolean deleteSharedPreferences(String name) {
    synchronized (ContextImpl.class) {
        final File prefs = getSharedPreferencesPath(name);
        final File prefsBackup = SharedPreferencesImpl.makeBackupFile(prefs);

        // Evict any in-memory caches
        final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
        cache.remove(prefs);

        prefs.delete();
        prefsBackup.delete();

        // We failed if files are still lingering
        return !(prefs.exists() || prefsBackup.exists());
    }
}
 
源代码5 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public boolean moveSharedPreferencesFrom(Context sourceContext, String name) {
    synchronized (ContextImpl.class) {
        final File source = sourceContext.getSharedPreferencesPath(name);
        final File target = getSharedPreferencesPath(name);

        final int res = moveFiles(source.getParentFile(), target.getParentFile(),
                source.getName());
        if (res > 0) {
            // We moved at least one file, so evict any in-memory caches for
            // either location
            final ArrayMap<File, SharedPreferencesImpl> cache =
                    getSharedPreferencesCacheLocked();
            cache.remove(source);
            cache.remove(target);
        }
        return res != -1;
    }
}
 
源代码6 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public boolean deleteSharedPreferences(String name) {
    synchronized (ContextImpl.class) {
        final File prefs = getSharedPreferencesPath(name);
        final File prefsBackup = SharedPreferencesImpl.makeBackupFile(prefs);

        // Evict any in-memory caches
        final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
        cache.remove(prefs);

        prefs.delete();
        prefsBackup.delete();

        // We failed if files are still lingering
        return !(prefs.exists() || prefsBackup.exists());
    }
}
 
源代码7 项目: android_9.0.0_r45   文件: Transition.java
/**
 * Match start/end values by Adapter view ID. Adds matched values to mStartValuesList
 * and mEndValuesList and removes them from unmatchedStart and unmatchedEnd, using
 * startIds and endIds as a guide for which Views have unique IDs.
 */
private void matchIds(ArrayMap<View, TransitionValues> unmatchedStart,
        ArrayMap<View, TransitionValues> unmatchedEnd,
        SparseArray<View> startIds, SparseArray<View> endIds) {
    int numStartIds = startIds.size();
    for (int i = 0; i < numStartIds; i++) {
        View startView = startIds.valueAt(i);
        if (startView != null && isValidTarget(startView)) {
            View endView = endIds.get(startIds.keyAt(i));
            if (endView != null && isValidTarget(endView)) {
                TransitionValues startValues = unmatchedStart.get(startView);
                TransitionValues endValues = unmatchedEnd.get(endView);
                if (startValues != null && endValues != null) {
                    mStartValuesList.add(startValues);
                    mEndValuesList.add(endValues);
                    unmatchedStart.remove(startView);
                    unmatchedEnd.remove(endView);
                }
            }
        }
    }
}
 
源代码8 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public boolean moveSharedPreferencesFrom(Context sourceContext, String name) {
    synchronized (ContextImpl.class) {
        final File source = sourceContext.getSharedPreferencesPath(name);
        final File target = getSharedPreferencesPath(name);

        final int res = moveFiles(source.getParentFile(), target.getParentFile(),
                source.getName());
        if (res > 0) {
            // We moved at least one file, so evict any in-memory caches for
            // either location
            final ArrayMap<File, SharedPreferencesImpl> cache =
                    getSharedPreferencesCacheLocked();
            cache.remove(source);
            cache.remove(target);
        }
        return res != -1;
    }
}
 
源代码9 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public boolean deleteSharedPreferences(String name) {
    synchronized (ContextImpl.class) {
        final File prefs = getSharedPreferencesPath(name);
        final File prefsBackup = SharedPreferencesImpl.makeBackupFile(prefs);

        // Evict any in-memory caches
        final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
        cache.remove(prefs);

        prefs.delete();
        prefsBackup.delete();

        // We failed if files are still lingering
        return !(prefs.exists() || prefsBackup.exists());
    }
}
 
源代码10 项目: android_9.0.0_r45   文件: AppOpsService.java
private void pruneOp(Op op, int uid, String packageName) {
    if (!op.hasAnyTime()) {
        Ops ops = getOpsRawLocked(uid, packageName, false /* edit */,
                false /* uidMismatchExpected */);
        if (ops != null) {
            ops.remove(op.op);
            if (ops.size() <= 0) {
                UidState uidState = ops.uidState;
                ArrayMap<String, Ops> pkgOps = uidState.pkgOps;
                if (pkgOps != null) {
                    pkgOps.remove(ops.packageName);
                    if (pkgOps.isEmpty()) {
                        uidState.pkgOps = null;
                    }
                    if (uidState.isDefault()) {
                        mUidStates.remove(uid);
                    }
                }
            }
        }
    }
}
 
源代码11 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public boolean moveSharedPreferencesFrom(Context sourceContext, String name) {
    synchronized (ContextImpl.class) {
        final File source = sourceContext.getSharedPreferencesPath(name);
        final File target = getSharedPreferencesPath(name);

        final int res = moveFiles(source.getParentFile(), target.getParentFile(),
                source.getName());
        if (res > 0) {
            // We moved at least one file, so evict any in-memory caches for
            // either location
            final ArrayMap<File, SharedPreferencesImpl> cache =
                    getSharedPreferencesCacheLocked();
            cache.remove(source);
            cache.remove(target);
        }
        return res != -1;
    }
}
 
源代码12 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public boolean deleteSharedPreferences(String name) {
    synchronized (ContextImpl.class) {
        final File prefs = getSharedPreferencesPath(name);
        final File prefsBackup = SharedPreferencesImpl.makeBackupFile(prefs);

        // Evict any in-memory caches
        final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
        cache.remove(prefs);

        prefs.delete();
        prefsBackup.delete();

        // We failed if files are still lingering
        return !(prefs.exists() || prefsBackup.exists());
    }
}
 
void detachLocked() {
    final int N = mMyObservers.size();
    for (int i=0; i<N; i++) {
        final ObserverInstance obs = mMyObservers.get(i);
        obs.mJobs.remove(this);
        if (obs.mJobs.size() == 0) {
            if (DEBUG) {
                Slog.i(TAG, "Unregistering observer " + obs + " for " + obs.mUri.getUri());
            }
            mContext.getContentResolver().unregisterContentObserver(obs);
            ArrayMap<JobInfo.TriggerContentUri, ObserverInstance> observerOfUser =
                    mObservers.get(obs.mUserId);
            if (observerOfUser !=  null) {
                observerOfUser.remove(obs.mUri);
            }
        }
    }
}
 
源代码14 项目: android_9.0.0_r45   文件: ContextImpl.java
@Override
public boolean deleteSharedPreferences(String name) {
    synchronized (ContextImpl.class) {
        final File prefs = getSharedPreferencesPath(name);
        final File prefsBackup = SharedPreferencesImpl.makeBackupFile(prefs);

        // Evict any in-memory caches
        final ArrayMap<File, SharedPreferencesImpl> cache = getSharedPreferencesCacheLocked();
        cache.remove(prefs);

        prefs.delete();
        prefsBackup.delete();

        // We failed if files are still lingering
        return !(prefs.exists() || prefsBackup.exists());
    }
}
 
源代码15 项目: android_9.0.0_r45   文件: Transition.java
/**
 * 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);
            }
        }
    }
}
 
源代码16 项目: AndroidComponentPlugin   文件: IntentResolver.java
private final void remove_all_objects(ArrayMap<String, F[]> map, String name,
        Object object) {
    F[] array = map.get(name);
    if (array != null) {
        int LAST = array.length-1;
        while (LAST >= 0 && array[LAST] == null) {
            LAST--;
        }
        for (int idx=LAST; idx>=0; idx--) {
            if (array[idx] == object) {
                final int remain = LAST - idx;
                if (remain > 0) {
                    System.arraycopy(array, idx+1, array, idx, remain);
                }
                array[LAST] = null;
                LAST--;
            }
        }
        if (LAST < 0) {
            map.remove(name);
        } else if (LAST < (array.length/2)) {
            F[] newa = newArray(LAST+2);
            System.arraycopy(array, 0, newa, 0, LAST+1);
            map.put(name, newa);
        }
    }
}
 
源代码17 项目: android_9.0.0_r45   文件: SnoozeHelper.java
protected void repostGroupSummary(String pkg, int userId, String groupKey) {
    if (mSnoozedNotifications.containsKey(userId)) {
        ArrayMap<String, ArrayMap<String, NotificationRecord>> keysByPackage
                = mSnoozedNotifications.get(userId);

        if (keysByPackage != null && keysByPackage.containsKey(pkg)) {
            ArrayMap<String, NotificationRecord> recordsByKey = keysByPackage.get(pkg);

            if (recordsByKey != null) {
                String groupSummaryKey = null;
                int N = recordsByKey.size();
                for (int i = 0; i < N; i++) {
                    final NotificationRecord potentialGroupSummary = recordsByKey.valueAt(i);
                    if (potentialGroupSummary.sbn.isGroup()
                            && potentialGroupSummary.getNotification().isGroupSummary()
                            && groupKey.equals(potentialGroupSummary.getGroupKey())) {
                        groupSummaryKey = potentialGroupSummary.getKey();
                        break;
                    }
                }

                if (groupSummaryKey != null) {
                    NotificationRecord record = recordsByKey.remove(groupSummaryKey);
                    mPackages.remove(groupSummaryKey);
                    mUsers.remove(groupSummaryKey);

                    if (record != null && !record.isCanceled) {
                        MetricsLogger.action(record.getLogMaker()
                                .setCategory(MetricsProto.MetricsEvent.NOTIFICATION_SNOOZED)
                                .setType(MetricsProto.MetricsEvent.TYPE_OPEN));
                        mCallback.repost(userId, record);
                    }
                }
            }
        }
    }
}
 
源代码18 项目: Synapse   文件: Versatile.java
/**
 * Solve TransitionManager leak problem
 */
public static void removeActivityFromTransitionManager(Activity activity) {
    final Class transitionManagerClass = TransitionManager.class;

    try {
        final Field runningTransitionsField = transitionManagerClass.getDeclaredField("sRunningTransitions");

        if (runningTransitionsField == null) {
            return;
        }

        runningTransitionsField.setAccessible(true);

        //noinspection unchecked
        final ThreadLocal<WeakReference<ArrayMap<ViewGroup, ArrayList<Transition>>>> runningTransitions
                = (ThreadLocal<WeakReference<ArrayMap<ViewGroup, ArrayList<Transition>>>>)
                runningTransitionsField.get(transitionManagerClass);

        if (runningTransitions == null
                || runningTransitions.get() == null
                || runningTransitions.get().get() == null) {
            return;
        }

        final ArrayMap map = runningTransitions.get().get();
        final View decorView = activity.getWindow().getDecorView();

        if (map.containsKey(decorView)) {
            map.remove(decorView);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码19 项目: android_9.0.0_r45   文件: IntentResolver.java
private final void remove_all_objects(ArrayMap<String, F[]> map, String name,
        Object object) {
    F[] array = map.get(name);
    if (array != null) {
        int LAST = array.length-1;
        while (LAST >= 0 && array[LAST] == null) {
            LAST--;
        }
        for (int idx=LAST; idx>=0; idx--) {
            if (array[idx] == object) {
                final int remain = LAST - idx;
                if (remain > 0) {
                    System.arraycopy(array, idx+1, array, idx, remain);
                }
                array[LAST] = null;
                LAST--;
            }
        }
        if (LAST < 0) {
            map.remove(name);
        } else if (LAST < (array.length/2)) {
            F[] newa = newArray(LAST+2);
            System.arraycopy(array, 0, newa, 0, LAST+1);
            map.put(name, newa);
        }
    }
}
 
源代码20 项目: android_9.0.0_r45   文件: FragmentTransition.java
/**
 * Finds the shared elements in the outgoing fragment. It also calls
 * {@link SharedElementCallback#onMapSharedElements(List, Map)} to allow more control
 * of the shared element mapping. {@code nameOverrides} is updated to match the
 * actual transition name of the mapped shared elements.
 *
 * @param nameOverrides A map of the shared element names from the starting fragment to
 *                      the final fragment's Views as given in
 *                      {@link FragmentTransaction#addSharedElement(View, String)}.
 * @param sharedElementTransition The shared element transition
 * @param fragments A structure holding the transitioning fragments in this container.
 * @return The mapping of shared element names to the Views in the hierarchy or null
 * if there is no shared element transition.
 */
private static ArrayMap<String, View> captureOutSharedElements(
        ArrayMap<String, String> nameOverrides, TransitionSet sharedElementTransition,
        FragmentContainerTransition fragments) {
    if (nameOverrides.isEmpty() || sharedElementTransition == null) {
        nameOverrides.clear();
        return null;
    }
    final Fragment outFragment = fragments.firstOut;
    final ArrayMap<String, View> outSharedElements = new ArrayMap<>();
    outFragment.getView().findNamedViews(outSharedElements);

    final SharedElementCallback sharedElementCallback;
    final ArrayList<String> names;
    final BackStackRecord outTransaction = fragments.firstOutTransaction;
    if (fragments.firstOutIsPop) {
        sharedElementCallback = outFragment.getEnterTransitionCallback();
        names = outTransaction.mSharedElementTargetNames;
    } else {
        sharedElementCallback = outFragment.getExitTransitionCallback();
        names = outTransaction.mSharedElementSourceNames;
    }

    outSharedElements.retainAll(names);
    if (sharedElementCallback != null) {
        sharedElementCallback.onMapSharedElements(names, outSharedElements);
        for (int i = names.size() - 1; i >= 0; i--) {
            String name = names.get(i);
            View view = outSharedElements.get(name);
            if (view == null) {
                nameOverrides.remove(name);
            } else if (!name.equals(view.getTransitionName())) {
                String targetValue = nameOverrides.remove(name);
                nameOverrides.put(view.getTransitionName(), targetValue);
            }
        }
    } else {
        nameOverrides.retainAll(outSharedElements.keySet());
    }
    return outSharedElements;
}