Intro To Android (Workbook 2)

Images

Image downloading was the wild west of the Android platform. Not only is it compicated to optimize images for different platforms, it's been historically hard to fetch, cache, and manage these images.

Everyone wrote their own version with varying levels of success. There were plenty of implementations out there for different parts of the caching, image handling, and networking.

Square has provided another helpful library to manage your image downloads: Picasso. In addition to the fetching and caching tools, it offers cropping and resizing tools.

To integrate the library, you can use maven:

<!--Image Handling-->
<dependency>
    <groupId>com.squareup.picasso</groupId>
    <artifactId>picasso</artifactId>
    <version>2.3.2</version>
</dependency>

It's a lightweight API that abstracts a lot of the complexity. Example:

Picasso.with( context )
       .load( imageUrl )
       .placeholder( R.drawable.placeholder )
       .into( holder.image );