Java Code Examples for android.support.v4.util.LongSparseArray#delete()

The following examples show how to use android.support.v4.util.LongSparseArray#delete() . 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: SkinCompatDrawableManager.java    From Android-skin-support with MIT License 6 votes vote down vote up
private Drawable getCachedDrawable(@NonNull final Context context, final long key) {
    synchronized (mDrawableCacheLock) {
        final LongSparseArray<WeakReference<ConstantState>> cache
                = mDrawableCaches.get(context);
        if (cache == null) {
            return null;
        }

        final WeakReference<ConstantState> wr = cache.get(key);
        if (wr != null) {
            // We have the key, and the secret
            ConstantState entry = wr.get();
            if (entry != null) {
                return entry.newDrawable(context.getResources());
            } else {
                // Our entry has been purged
                cache.delete(key);
            }
        }
    }
    return null;
}
 
Example 2
Source File: LollipopDrawablesCompat.java    From RippleDrawable with MIT License 5 votes vote down vote up
private static Drawable getCachedDrawable(LongSparseArray<WeakReference<Drawable.ConstantState>> cache,
                                          long key, Resources res) {
    synchronized (mAccessLock) {
        WeakReference<Drawable.ConstantState> wr = cache.get(key);
        if (wr != null) {
            Drawable.ConstantState entry = wr.get();
            if (entry != null) {
                return entry.newDrawable(res);
            } else {
                cache.delete(key);
            }
        }
    }
    return null;
}