Skip to content

Commit 640d0a2

Browse files
committed
use hasmap for SoftMemoryCacheImpl cache
1 parent 0f0443f commit 640d0a2

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/net/tsz/afinal/bitmap/core/SoftMemoryCacheImpl.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,16 @@
1616
package net.tsz.afinal.bitmap.core;
1717

1818
import java.lang.ref.SoftReference;
19-
20-
import net.tsz.afinal.utils.Utils;
19+
import java.util.HashMap;
2120

2221
import android.graphics.Bitmap;
2322

2423
public class SoftMemoryCacheImpl implements IMemoryCache {
2524

26-
private final LruMemoryCache<String, SoftReference<Bitmap>> mMemoryCache;
25+
private final HashMap<String, SoftReference<Bitmap>> mMemoryCache;
2726

2827
public SoftMemoryCacheImpl(int size) {
29-
mMemoryCache = new LruMemoryCache<String, SoftReference<Bitmap>>(size) {
30-
@Override
31-
protected int sizeOf(String key, SoftReference<Bitmap> sBitmap) {
32-
final Bitmap bitmap = sBitmap==null ? null : sBitmap.get();
33-
if(bitmap == null)
34-
return 1;
35-
return Utils.getBitmapSize(bitmap);
36-
}
37-
};
28+
mMemoryCache = new HashMap<String, SoftReference<Bitmap>>(size);
3829
}
3930

4031
@Override
@@ -53,7 +44,7 @@ public Bitmap get(String key) {
5344

5445
@Override
5546
public void evictAll() {
56-
mMemoryCache.evictAll();
47+
mMemoryCache.clear();
5748
}
5849

5950
@Override

0 commit comments

Comments
 (0)