Underwave is a simple library to asynchronously download and load images to views, with memory and disk caching, resource pooling, and request cancellation support.
Underwave can be used to load images to simple views or lists of views with efficiency.
To add Underwave to your project, add the following line to your build.gradle
:
implementation "com.aallam.underwave:underwave-android:0.1.0"
Underwave API is simple and straightforward:
Use load
function to load an image to an ImageView, :
Underwave.with(context).load("https://www.example.com/image.jpg", imageView)
imageView.load("https://www.example.com/image.jpg")
Use insert
function to take advantage of a custom coroutine scope (UI scope for example):
uiScope.launch {
Underwave.with(context).insert("https://www.example.com/image.jpg", imageView)
}
uiScope.launch {
imageView.insert("https://www.example.com/image.jpg")
}
Call cancel()
on Request
object to cancel the loading operation:
val request = Underwave.with(context).load("https://www.example.com/image.jpg", imageView)
//...
request.cancel()
val request = imageView.insert("https://www.example.com/image.jpg")
//...
request.cancel()
- Min SDK 21
- Compile SDK: 29+
- AndroidX
- Java 8+
If you use Proguard, you may need to add rules for coroutines.
Underwave is distributed under the terms of the Apache License (Version 2.0). See LICENSE for details.