Parrot
A kotlin extension to load easily remote images in your ImageView
.
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 urlplaceholder
, optional bitmap placeholder or resource Idcaching
, you can set your favorite caching system, see belowmanipulate
, optional callback returns the image before setting to your imageview, here you can tweak the imageonPlaceholder
, optional callback returns if a placeholder has been setonComplete
, 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 netNetThenDisk
, 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