https://github.com/sephiroth74/disklruimagecache
Simple file based image cache
https://github.com/sephiroth74/disklruimagecache
Last synced: 9 months ago
JSON representation
Simple file based image cache
- Host: GitHub
- URL: https://github.com/sephiroth74/disklruimagecache
- Owner: sephiroth74
- License: unlicense
- Created: 2014-02-11T21:28:50.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-09T21:22:15.000Z (over 11 years ago)
- Last Synced: 2025-03-30T01:23:40.653Z (10 months ago)
- Language: Java
- Size: 219 KB
- Stars: 4
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
DiskLruImageCache
=================
Simple file based image cache
Include
=================
Just add the following line to your build.gradle dependencies
compile "it.sephiroth.android.library.disklruimagecache:DiskLruImageCache:1.0.0"
Usage
=================
DiskLruImageCache cache = new DiskLruImageCache( context, "my-unique-name", Integer.MAX_VALUE );
Read an entry from the cache
DiskLruImageCache.BitmapEntry entry = cache.get( "image-1", Metadata.class );
Write an entry
Metadata metadata = new Metadata();
metadata.value = 1;
DiskLruImageCache.BitmapEntry entry;
entry = new DiskLruImageCache.BitmapEntry( bitmap, metadata );
boolean success = cache.put( "image-1", entry, Bitmap.CompressFormat.JPEG, 70 );
The Metadata must be an instance of Parcelable, in this example is:
static class Metadata implements Parcelable {
int value;
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public Metadata createFromParcel ( Parcel source ) {
final Metadata f = new Metadata();
f.value = source.readInt();
return f;
}
@Override
public Metadata[] newArray ( final int i ) {
return new Metadata[0];
}
};
@Override
public int describeContents () {
return 0;
}
@Override
public void writeToParcel ( final Parcel parcel, final int i ) {
parcel.writeInt( value );
}
}