A simple way to handle remote image in Kotlin.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github
.idea
app
gradle/wrapper
.gitignore
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

Parrot

A kotlin extension to load easily remote images in your ImageView.

parrot

Install

Add to gradle in allprojects

maven { url 'https://jitpack.io' }

then add this

compile 'com.github.matteocrippa:Parrot:0.0.6'

Usage

Parrot needs to be init once, passing the app context:

Parrot(context)

then provides you a simple function to tame all your needs:

ImageView.load

This function has the following parameters:

  • url, optional string with current remote image url
  • placeholder, optional bitmap placeholder or resource Id
  • caching, you can set your favorite caching system, see below
  • manipulate, optional callback returns the image before setting to your imageview, here you can tweak the image
  • onPlaceholder, optional callback returns if a placeholder has been set
  • onComplete, optional callback returns when the image has been applied to the imageview

Caching

Parrot provide an easy way to handle images caching:

  • NetOnly, default option, force always reloading from net
  • NetThenDisk, download once and use local version

Examples

Simple usage

imageView.loadImage("http://the-most-awesome-image.png")

Callback usage

imageView.loadImage("http://the-most-awesome-image.png", 
    manipulate = { bitmap ->
        // alter bitmap
        bitmap
    }, onComplete = { completed ->
        // do something
    }                                        

Credits

Icon is taken by free emojii set by Vincent Le Moign