# Coercing Picasso To Play With Palette

DevFeed: [Coercing Picasso To Play With Palette](<https://devfeed.tech/articles/coercing-picasso-to-play-with-palette-20923.md>)

Original publisher: [Read original article](<https://jakewharton.com/coercing-picasso-to-play-with-palette/>)

Published: 2014-10-24T00:00:00Z

Content type: tutorial

Language: en

Sources: [Jake Wharton](<https://devfeed.tech/sources/jake-wharton.md>)

Topics: [Picasso](<https://devfeed.tech/topics/picasso.md>), [Image](<https://devfeed.tech/topics/image.md>), [API](<https://devfeed.tech/topics/api.md>), [Library](<https://devfeed.tech/topics/library.md>), [Android](<https://devfeed.tech/topics/android.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [image](<https://devfeed.tech/tags/image.md>), [library](<https://devfeed.tech/tags/library.md>), [main-thread](<https://devfeed.tech/tags/main-thread.md>), [picasso](<https://devfeed.tech/tags/picasso.md>), [pipeline](<https://devfeed.tech/tags/pipeline.md>)

## AI overview

This article explores how to adapt Picasso's existing APIs to work with the Palette library before direct support is available. It focuses on Bitmap handling, callback behavior, and Picasso's threading model for performing Palette computation without blocking the Android main thread.

## Source excerpt

Features feel how I imagine children would. They are relatively easy to spawn but require a lengthy committment and constant care. Picasso's API would be nothing short of a Greek tragedy if we humored every feature request that we received. Finding the right balance of what is appropriate to add and what isn't is a constant struggle. When the Palette library was teased the inevitable feature request came in to Picasso for a means of supporting it. This was certainly not an unreasonable request, and while we might not explicitly support it directly we will probably add something in the future to more easily facilitate its use. But what do we do in the interim? The API for proper support is many months if not a year away from actually being implemented. Let's walk through an attempt to adapt the existing APIs to allow Palette's use. The fundamental component of Picasso's data pipeline after the request has been fulfilled is a Bitmap. We use this in the return values and method parameters which traverse upwards to the main thread. Bitmap is a final class in Android so we will not get an opportunity to hang extra metadata on a subclass. There are two ways that Picasso can notify the caller of a successful image download: the Callback when loading directly into an ImageView or the more generalized Target. A Target is given direct access to the Bitmap object but the Callback is not (although you can get it indirectly with some cleverness). Regardless of Bitmap access is the problem that both of these are called on the main thread. Since Palette does a decent amount of computation we don't want to do it here anyways. Palette actually has an asynchronous mode of operation that we could leverage in these two callback locations but you wouldn't want to. The images are ready to be displayed when the callbacks are invoked so either delaying display until you can run Palette on another background thread or displaying the image right away and getting the Palette information later