Back to project page Android-ImageManager.
The source code is released under:
Copyright (c) 2011 Felipe Lima Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Softwa...
If you think the Android project Android-ImageManager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.felipecsl.android.imaging; //w w w . j a v a2s . c o m import android.graphics.Bitmap; import android.support.v4.util.LruCache; import com.felipecsl.android.Utils; public class MemoryLruImageCache extends LruCache<String, Bitmap> { private MemoryCacheEntryRemovedCallback onEntryRemovedCallback; public static interface MemoryCacheEntryRemovedCallback { void onEntryRemoved(boolean evicted, String key, Bitmap oldValue, Bitmap newValue); } public MemoryLruImageCache(final int cacheSizeInKb) { super(cacheSizeInKb); } public void setEntryRemovedCallback(final MemoryCacheEntryRemovedCallback onEntryRemovedCallback) { this.onEntryRemovedCallback = onEntryRemovedCallback; } @Override protected int sizeOf(final String key, final Bitmap bitmap) { // The cache size will be measured in kilobytes rather than number of items. return Utils.getSizeInBytes(bitmap) / 1024; } @Override protected void entryRemoved(final boolean evicted, final String key, final Bitmap oldValue, final Bitmap newValue) { super.entryRemoved(evicted, key, oldValue, newValue); if (onEntryRemovedCallback != null) { onEntryRemovedCallback.onEntryRemoved(evicted, key, oldValue, newValue); } } }