Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steelkiwi/android-image-worker-library
Android library that helps you downloading and storing images.
https://github.com/steelkiwi/android-image-worker-library
Last synced: 7 days ago
JSON representation
Android library that helps you downloading and storing images.
- Host: GitHub
- URL: https://github.com/steelkiwi/android-image-worker-library
- Owner: steelkiwi
- Created: 2013-08-27T08:04:38.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-10-09T12:45:59.000Z (about 11 years ago)
- Last Synced: 2023-08-03T09:38:14.404Z (over 1 year ago)
- Language: Java
- Size: 676 KB
- Stars: 6
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
Android Image Worker Library
================================ImageManager is Android library that helps you to simplify operations of downloading and displaying images.
ImageManager supports memory & disc cache, allows you to download and save bitmaps asynchronously. It uses thread pool
to run tasks simultaneously. You can create an instance using a Builder object:```java
ImageManager manager = new ImageManager.Builder(Context context)
.memoryPercentAvailable(0.2f) // fraction of all application memory that will be used by cache.
.threads(3) // maximum parallelly downloaded threads.
.build();
```
Downloading.
------------------------------Every single download is described by DownloadTask e.g.:
```java
DownloadTask task = new DownloadTask.Builder()
.url(String some_picture_url) // image url.
.mCache() // result of task execution will be cached in memory.
.dCache() // result of task execution will be cached on local filesystem.
.loadTo(ImageView some_view) // bitmap will be placed to specified ImageView.
.downloadCallback(ImageLoaderCallback callback) // after successfull download ImageLoaderCallback will be notified with Bitmap.
.config(Bitmap.Config config) // specified config will be used to decode image.
.animation(Animation a) // ImageView will be animated after Bitmap set to it.
.scaleToProportionally(int maxWidth, int maxHeight) // Bitmap will be scaled to match specified dimensions with saving proportions.
.cropToSquare() // Crop effect will be applied to download result.
.placeholder(int placeholderDrawable) // Stub drawable will be shown while image loading procedure.
.build();
```Also you can load an image from filesystem using .file(String path) instead of .url(String url).
After task created you can run it using ImageManager:```java
manager.loadImage(DownloadTask task);
```Saving.
--------------------To save some Bitmap you've created (or got in another way than ImageManager) you can use SaveBitmapTask:
```java
SaveBitmapTask task = new SaveBitmapTask.Builder(Bitmap bm)
.compressionListener(BitmapCompressionListener listener) // listener that will be notified after bitmap compression is completed (success or fail).
.compressTo(CompressFormat format) // CompressFormat to save bitmap. CompressFormat.PNG will be used by default.
.saveToFile(String path) // Path to save bitmap, unnecessary param.
.setTag(String tag) // Tag that describes this SaveBitmapTask.
.compressionQuality(int quality) // Compression quality.
```
After creating it you can execute SaveBitmapTask using ImageManager:```java
manager.save(SaveBitmapTask task);
```