@Nullablepublic static Bitmap decodeResourceStream(@Nullable Resources res, @Nullable TypedValue value, @Nullable InputStream is, @Nullable Rect pad, @Nullable Options opts) { validate(opts); if (opts == null) { opts = new Options(); } if (opts.inDensity == 0 && value != null) { final int density = value.density; if (density == TypedValue.DENSITY_DEFAULT) { opts.inDensity = DisplayMetrics.DENSITY_DEFAULT; } else if (density != TypedValue.DENSITY_NONE) { opts.inDensity = density; } } if (opts.inTargetDensity == 0 && res != null) { opts.inTargetDensity = res.getDisplayMetrics().densityDpi; } return decodeStream(is, pad, opts);}
public void trimToSize(int maxSize) { while(true) { Object key; Object value; synchronized(this) { if (this.size < 0 || this.map.isEmpty() && this.size != 0) { throw new IllegalStateException(this.getClass().getName() ".sizeOf() is reporting inconsistent results!"); } if (this.size <= maxSize || this.map.isEmpty()) { return; } Entry<K, V> toEvict = (Entry)this.map.entrySet().iterator().next(); key = toEvict.getKey(); value = toEvict.getValue(); this.map.remove(key); //计算现在缓存的大小,然后减掉多余的,内部调用的是sizeOf()方法 this.size -= this.safeSizeOf(key, value); this.evictionCount; } //如果你想在在我们的缓存中实现二级缓存,可以实现此方法,源码中是空方法。 this.entryRemoved(true, key, value, (Object)null); }}
联系客服