Parrot

Additional

Language
Kotlin
Version
N/A
Created
Dec 23, 2017
Updated
Aug 22, 2018 (Retired)
Owner
Matteo Crippa (matteocrippa)
Contributor
Matteo Crippa (matteocrippa)
1
Activity
Badge
Generate
Download
Source code

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