Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

hendraanggrian/picasso-ktx

Repository files navigation

Travis CI Maven Central

Picasso KTX

Deprecated

This library is no longer maintained, use coil-kt instead.

Transformation demo Palette demo

Kotlin extensions for Picasso image loader.

  • Invoke callback and target with Kotlin DSL.
  • Use pre-loaded transformations with extension functions.
  • Supports material components Palette alongside too.

Download

dependencies {
    compile "com.hendraanggrian.appcompat:picasso-ktx:$version"
}

Snapshots of the development version are available in Sonatype's snapshots repository.

Usage

Common

Call picasso to get global instance of Picasso. Or buildPicasso to invoke Picasso.Builder.

picasso.load(url).into(imageView)

val myPicasso = buildPicasso {
    loggingEnabled(true)
    memoryCache(Cache.NONE)
    listener { picasso, uri, exception -> }
}
myPicasso.load(url).into(imageView)

Clean declaration of Callback when loading images into ImageView.

picasso.load(url).into(imageView) {
    onSuccess {
        celebrate()
    }
}

Or into Target with Kotlin DSL.

picasso.load(url).into {
    onLoaded { bitmap, from ->
        process(bitmap)
    }
}

Transformations

Transform request using Kotlin extension functions.

picasso.load(url)
    .circle()
    .into(imageView)

// multiple transformations are also supported
picasso.load(url)
    .circle()
    .grayscale()
    .into(imageView)

Available transformations

Transformations
crop square square()
crop circle circle()
crop rounded rounded(radius)
rounded(radius, margin)<br> rounded(radius, margin, usedDp)
overlay overlay(color, alpha)
overlay(context, colorRes, alpha)
grayscale grayscale()