@@ -349,30 +349,27 @@ 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
- }
352
+ /**
353
+ * Sets maximum memory cache size (in percent of available app memory) for {@link android.graphics.Bitmap
354
+ * bitmaps}.<br />
355
+ * Default value - 1/8 of available app memory.<br />
356
+ * <b>NOTE:</b> If you use this method then
357
+ * {@link com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache LruMemoryCache} will be used as
358
+ * memory cache. You can use {@link #memoryCache(MemoryCacheAware)} method to set your own implementation of
359
+ * {@link MemoryCacheAware}.
360
+ */
361
+ public Builder memoryCacheSizePercentage (int avaialbleMemoryPercent ) {
362
+ if (avaialbleMemoryPercent <= 0 || avaialbleMemoryPercent >= 100 )
363
+ throw new IllegalArgumentException ("avaialbleMemoryPercent must be in range (0 < % < 100)" );
364
+
365
+ if (memoryCache != null ) {
366
+ L .w (WARNING_OVERLAP_MEMORY_CACHE );
367
+ }
368
+
369
+ long availableMemory = Runtime .getRuntime ().maxMemory ();
370
+ memoryCacheSize = (int ) (availableMemory * (avaialbleMemoryPercent / 100f ));
371
+ return this ;
372
+ }
376
373
377
374
/**
378
375
* Sets memory cache for {@link android.graphics.Bitmap bitmaps}.<br />
0 commit comments