Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

Commit

Permalink
Rename recycle policy Builder mutator.
Browse files Browse the repository at this point in the history
Previous name implies that it only happens when the memory cache enabled, which is incorrect.
  • Loading branch information
Chris Banes committed Feb 2, 2013
1 parent 0b513f5 commit 327e2fb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions library/src/uk/co/senab/bitmapcache/BitmapLruCache.java
Expand Up @@ -67,7 +67,7 @@ public class BitmapLruCache {
/**
* The recycle policy controls if the {@link android.graphics.Bitmap#recycle()} is automatically called, when it is
* no longer being used. To set this, use the
* {@link Builder#setMemoryCacheRecyclePolicy(uk.co.senab.bitmapcache.BitmapLruCache.RecyclePolicy) Builder.setMemoryCacheRecyclePolicy()} method.
* {@link Builder#setRecyclePolicy(uk.co.senab.bitmapcache.BitmapLruCache.RecyclePolicy) Builder.setRecyclePolicy()} method.
*/
public static enum RecyclePolicy {
/**
Expand Down Expand Up @@ -558,7 +558,7 @@ private static long getHeapSize() {

private boolean mMemoryCacheEnabled;
private int mMemoryCacheMaxSize;
private RecyclePolicy mMemoryRecyclePolicy;
private RecyclePolicy mRecyclePolicy;

public Builder() {
// Disk Cache is disabled by default, but it's default size is set
Expand All @@ -567,7 +567,7 @@ public Builder() {
// Memory Cache is enabled by default, with a small maximum size
mMemoryCacheEnabled = true;
mMemoryCacheMaxSize = DEFAULT_MEM_CACHE_MAX_SIZE_MB * MEGABYTE;
mMemoryRecyclePolicy = DEFAULT_RECYCLE_POLICY;
mRecyclePolicy = DEFAULT_RECYCLE_POLICY;
}

/**
Expand All @@ -584,7 +584,7 @@ public BitmapLruCache build() {
memoryCache = new BitmapMemoryLruCache(mMemoryCacheMaxSize);
}

final BitmapLruCache cache = new BitmapLruCache(memoryCache, mMemoryRecyclePolicy);
final BitmapLruCache cache = new BitmapLruCache(memoryCache, mRecyclePolicy);

if (isValidOptionsForDiskCache()) {
new AsyncTask<Void, Void, DiskLruCache>() {
Expand Down Expand Up @@ -692,24 +692,24 @@ public Builder setMemoryCacheMaxSizeUsingHeapSize() {
* methods.
*/
public Builder setMemoryCacheMaxSizeUsingHeapSize(float percentageOfHeap) {
int size = (int) Math.round(getHeapSize() * Math.min(percentageOfHeap, MAX_MEMORY_CACHE_HEAP_RATIO));
int size = Math.round(getHeapSize() * Math.min(percentageOfHeap, MAX_MEMORY_CACHE_HEAP_RATIO));
return setMemoryCacheMaxSize(size);
}

/**
* Sets the recycle policy for the memory cache. This controls if/when {@link android.graphics.Bitmap#recycle()}
* Sets the recycle policy. This controls if {@link android.graphics.Bitmap#recycle()}
* is called.
*
* @param recyclePolicy - New recycle policy, can not be null.
* @return This Builder object to allow for chaining of calls to set
* methods.
*/
public Builder setMemoryCacheRecyclePolicy(RecyclePolicy recyclePolicy) {
public Builder setRecyclePolicy(RecyclePolicy recyclePolicy) {
if (null == recyclePolicy) {
throw new IllegalArgumentException("The recycle policy can not be null");
}

mMemoryRecyclePolicy = recyclePolicy;
mRecyclePolicy = recyclePolicy;
return this;
}

Expand Down

0 comments on commit 327e2fb

Please sign in to comment.