Skip to content
This repository has been archived by the owner on Mar 23, 2020. It is now read-only.

Latest commit

 

History

History
82 lines (68 loc) · 2.64 KB

README.md

File metadata and controls

82 lines (68 loc) · 2.64 KB

Underwave: Background Image-Loading Library

Build Status Documentation Download codebeat badge

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.

Usage

To add Underwave to your project, add the following line to your build.gradle:

implementation "com.aallam.underwave:underwave-android:0.1.0"

Quick Start

Underwave API is simple and straightforward:

Simple

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")

Scoped

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")
}

Cancellation

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()

Requirements

  • Min SDK 21
  • Compile SDK: 29+
  • AndroidX
  • Java 8+

R8 / Proguard

If you use Proguard, you may need to add rules for coroutines.

License

Underwave is distributed under the terms of the Apache License (Version 2.0). See LICENSE for details.