项目作者: Aallam

项目描述 :
Underwave: a background image-loading library
高级语言: Kotlin
项目地址: git://github.com/Aallam/Underwave.git
创建时间: 2019-12-19T19:02:30Z
项目社区:https://github.com/Aallam/Underwave

开源协议:Apache License 2.0

下载


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:

  1. 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, :

  1. Underwave.with(context).load("https://www.example.com/image.jpg", imageView)
  1. imageView.load("https://www.example.com/image.jpg")

Scoped

Use insert function to take advantage of a custom coroutine scope (UI scope for example):

  1. uiScope.launch {
  2. Underwave.with(context).insert("https://www.example.com/image.jpg", imageView)
  3. }
  1. uiScope.launch {
  2. imageView.insert("https://www.example.com/image.jpg")
  3. }

Cancellation

Call cancel() on Request object to cancel the loading operation:

  1. val request = Underwave.with(context).load("https://www.example.com/image.jpg", imageView)
  2. //...
  3. request.cancel()
  1. val request = imageView.insert("https://www.example.com/image.jpg")
  2. //...
  3. 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.