File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
library/src/com/nostra13/universalimageloader/core Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -349,6 +349,31 @@ public Builder memoryCacheSize(int memoryCacheSize) {
349
349
return this ;
350
350
}
351
351
352
+ /**
353
+ * Sets maximum memory cache size percent in system memory for {@link android.graphics.Bitmap bitmaps} (in bytes).<br />
354
+ * Default value - 1/8 of available app memory.<br />
355
+ * <b>NOTE:</b> If you use this method then
356
+ * {@link com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache LruMemoryCache} will be used as
357
+ * memory cache. You can use {@link #memoryCache(MemoryCacheAware)} method to set your own implementation of
358
+ * {@link MemoryCacheAware}.
359
+ */
360
+ public Builder memoryCachePercent (int memoryCachePercent ) {
361
+ if (memoryCachePercent <= 0 ) throw new IllegalArgumentException ("memoryCacheSize must be a positive number" );
362
+
363
+ if (memoryCache != null ) {
364
+ L .w (WARNING_OVERLAP_MEMORY_CACHE );
365
+ }
366
+
367
+ if (memoryCachePercent > 80 ) {
368
+ memoryCachePercent = 80 ;
369
+ }
370
+ int capacity = (int ) ((Runtime .getRuntime ().maxMemory () * (memoryCachePercent / 100f )));
371
+ if (capacity > 0 ) {
372
+ this .memoryCacheSize = capacity ;
373
+ }
374
+ return this ;
375
+ }
376
+
352
377
/**
353
378
* Sets memory cache for {@link android.graphics.Bitmap bitmaps}.<br />
354
379
* Default value - {@link com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache LruMemoryCache}
You can’t perform that action at this time.
0 commit comments