@Override void put(int key, Object object) { mCache.put(key, object); } }
public void putImagesCache(String groundOverlayUrl, Bitmap bitmap) { mImagesCache.put(groundOverlayUrl, bitmap); }
private void addVideoThumbToCache(String path, Bitmap bitmap) { if (getVideoThumbToCache(path) == null && bitmap != null) { // 当前地址没有缓存时,就添加 lruCache.put(path, bitmap); } }
public static int parseColor(String colorString, int defaultColor) { try { Integer integer = colorCache.get(colorString); if (integer != null) { return integer.intValue(); } else { integer = Color.parseColor(colorString); colorCache.put(colorString, integer); return integer.intValue(); } } catch (Exception e) { return defaultColor; } }
public static int parseColor(String colorString, int defaultColor) { try { Integer integer = colorCache.get(colorString); if (integer != null) { return integer.intValue(); } else { integer = Color.parseColor(colorString); colorCache.put(colorString, integer); return integer.intValue(); } } catch (Exception e) { return defaultColor; } }
public <T extends Serializable> boolean put(@NonNull final String key, @NonNull T item, @NonNull final Class<T> type) { if (DEBUG) Log.d(TAG, "put() called with: key = [" + key + "], item = [" + item + "]"); synchronized (lruCache) { try { lruCache.put(key, new CacheData<>(clone(item, type), type)); return true; } catch (final Exception error) { Log.e(TAG, "Serialization failed for: ", error); } } return false; }
private Set<? extends Cluster<T>> getClustersInternal(int discreteZoom) { Set<? extends Cluster<T>> results; mCacheLock.readLock().lock(); results = mCache.get(discreteZoom); mCacheLock.readLock().unlock(); if (results == null) { mCacheLock.writeLock().lock(); results = mCache.get(discreteZoom); if (results == null) { results = mAlgorithm.getClusters(discreteZoom); mCache.put(discreteZoom, results); } mCacheLock.writeLock().unlock(); } return results; }
public void putInfo(int serviceId, @NonNull String url, @NonNull Info info) { if (DEBUG) Log.d(TAG, "putInfo() called with: info = [" + info + "]"); final long expirationMillis = ServiceHelper.getCacheExpirationMillis(info.getServiceId()); synchronized (lruCache) { final CacheData data = new CacheData(info, expirationMillis); lruCache.put(keyOf(serviceId, url), data); } }
@Nullable public Drawable get(int resId, Resources resources, @Nullable Resources.Theme theme) { SimplePoolWithCount<Drawable> drawablesPool = mDrawableCache.get(resId); if (drawablesPool == null) { drawablesPool = new SimplePoolWithCount<>(DRAWABLES_POOL_MAX_ITEMS); mDrawableCache.put(resId, drawablesPool); } Drawable drawable = drawablesPool.acquire(); if (drawable == null) { drawable = ResourcesCompat.getDrawable(resources, resId, theme); } // We never want this pool to remain empty otherwise we would risk to resolve a new drawable // when get is called again. So if the pool is about to drain we just put a new Drawable in it // to keep it warm. if (drawable != null && drawablesPool.getPoolSize() == 0) { drawablesPool.release(drawable.getConstantState().newDrawable()); } return drawable; }
public Where build(Constraint constraint, StringBuilder stringBuilder) { final boolean cacheable = isCacheable(constraint); final long cacheKey = cacheKey(constraint); Where where = cacheable ? queryCache.get(cacheKey) : null; if (where == null) { // build it where = createWhere(cacheKey, constraint, stringBuilder); if (cacheable) { queryCache.put(cacheKey, where); } } fillWhere(constraint, where); return where; }
@Override public void onSuccess(GalleryDetail result) { getApplication().removeGlobalStuff(this); // Put gallery detail to cache EhApplication.getGalleryDetailCache(getApplication()).put(result.gid, result); // Add history EhDB.putHistoryInfo(result); // Notify success GalleryDetailScene scene = getScene(); if (scene != null) { scene.onGetGalleryDetailSuccess(result); } }
public void release(Drawable drawable, int resId) { SimplePoolWithCount<Drawable> drawablesPool = mDrawableCache.get(resId); if (drawablesPool == null) { drawablesPool = new SimplePoolWithCount<>(DRAWABLES_POOL_MAX_ITEMS); mDrawableCache.put(resId, drawablesPool); } // Reset a stateful drawable, and its animations, before being released. if (drawable.isStateful()) { drawable.setState(StateSet.WILD_CARD); if (SDK_INT >= HONEYCOMB) { drawable.jumpToCurrentState(); } } drawablesPool.release(drawable); }
@Override public synchronized void put(String key, Object value) { if (TextUtils.isEmpty(key)) return; if (cache.get(key) != null) { cache.remove(key); } cache.put(key, value); }
@Override protected Bitmap doInBackground(Void... a) { Bitmap bmp = mMediaFile.getVideoFrameByIndex(mIndex, true, THUMBNAIL_EDGE, THUMBNAIL_EDGE).toBitmap(); mBitmapCache.put(mIndex, bmp); return bmp; }
sCache.put(hashCode, layout);
@Override public void onCreateBitmap(Bitmap newBitmap) { if (!lis.isEmpty()) { mLruCaches.put(lis.get(position), newBitmap); } } });
public void addVideoThumbToCache(String path,Bitmap bitmap){ if(getVideoThumbToCache(path) == null){ //当前地址没有缓存时,就添加 lruCache.put(path, bitmap); } } public Bitmap getVideoThumbToCache(String path){
public synchronized void pushBitmap(Bitmap bitmap) { String key = KEY_INDEX + writeIndex; writeIndex++; if (sizeCount < memorySize * 0.8f) { mLruCache.put(key, bitmap); sizeCount += bitmap.getByteCount(); } else { saveToDiskCache(key, bitmap); } }
@Override public ClusterOptions getClusterOptions(List<Marker> markers) { int count = markers.size(); BitmapDescriptor icon = cache.get(count); if (icon == null) { icon = createIcon(count); cache.put(count, icon); } clusterOptions.icon(icon); return clusterOptions; }
public void addInCache(BitmapHolder h) { if (mBitmapCache.get(h.getName()) == null) { mBitmapCache.put(h.getName(), h); } }