Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabrielbb/android-bitmap-diskcache
Java implementation of a Disk-based LRU cache for Android Bitmaps
https://github.com/gabrielbb/android-bitmap-diskcache
android bitmap disk-cache lru-cache
Last synced: 15 days ago
JSON representation
Java implementation of a Disk-based LRU cache for Android Bitmaps
- Host: GitHub
- URL: https://github.com/gabrielbb/android-bitmap-diskcache
- Owner: GabrielBB
- Created: 2018-12-09T14:31:36.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-13T18:01:52.000Z (about 5 years ago)
- Last Synced: 2024-10-04T17:42:04.927Z (about 1 month ago)
- Topics: android, bitmap, disk-cache, lru-cache
- Language: Java
- Homepage:
- Size: 7.81 KB
- Stars: 9
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Android-Bitmap-DiskCache
Java implementation of a Disk-based LRU cache for Android Bitmaps. This is an asynchronous implementation of [JakeWharton's DiskLruCache](https://github.com/JakeWharton/DiskLruCache) targeted for bitmaps and easier to use
### Requirements
1 - Add the following library to your `build.gradle`:
```groovy
implementation 'com.jakewharton:disklrucache:2.0.2'
```2 - Copy the BitmapDiskCache class that you can find in this repo to your project
### Usage
You can instantiate the BitmapDiskCache in your activity like this:
```java
final BitmapDiskCache cache = new BitmapDiskCache(getApplicationContext());
```You can add bitmaps to the cache and get the assigned key like this:
```java
cache.add(someBitmap, key -> {
// Store the key
});
```You can retrieve a bitmap by its key like this:
```java
cache.get(key, bitmap -> {
// Use bitmap
});
```When you finish using the cache or when your activity finishes you need to close the cache reference:
```java
cache.close();
```