StatsSnapshot createSnapshot() { return new StatsSnapshot(cache.maxSize(), cache.size(), cacheHits, cacheMisses, totalDownloadSize, totalOriginalBitmapSize, totalTransformedBitmapSize, averageDownloadSize, averageOriginalBitmapSize, averageTransformedBitmapSize, downloadCount, originalBitmapCount, transformedBitmapCount, System.currentTimeMillis()); }
void set(@NonNull String key, @NonNull Bitmap bitmap) { if (key == null || bitmap == null) { throw new NullPointerException("key == null || bitmap == null"); } int byteCount = BitmapCompat.getAllocationByteCount(bitmap); // If the bitmap is too big for the cache, don't even attempt to store it. Doing so will cause // the cache to be cleared. Instead just evict an existing element with the same key if it // exists. if (byteCount > maxSize()) { cache.remove(key); return; } cache.put(key, new BitmapAndSize(bitmap, byteCount)); }