package cn.net.caoyao.cpzshandset.common.bitmap.core;



import android.graphics.Bitmap;
import cn.net.caoyao.cpzshandset.common.bitmap.display.Utils;

public class BaseMemoryCacheImpl
  implements IMemoryCache
{
  private final LruMemoryCache<String, Bitmap> mMemoryCache;

  @SuppressWarnings("unchecked")
public BaseMemoryCacheImpl(int size)
  {
    this.mMemoryCache = new LruMemoryCache(size)
    {
      protected int sizeOf(String key, Bitmap bitmap) {
        return Utils.getBitmapSize(bitmap);
      }
    };
  }

  public void put(String key, Bitmap bitmap) {
    this.mMemoryCache.put(key, bitmap);
  }

  public Bitmap get(String key)
  {
    return (Bitmap)this.mMemoryCache.get(key);
  }

  public void evictAll()
  {
    this.mMemoryCache.evictAll();
  }

  public void remove(String key)
  {
    this.mMemoryCache.remove(key);
  }
}