Last active
August 29, 2015 14:01
-
-
Save matthew-carroll/2e8932493d0020635147 to your computer and use it in GitHub Desktop.
Introduction to Picasso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Picasso canonical usage. Notice the elegance of the method chaining | |
Picasso.with(context).load(imageUrl).into(myImageView); | |
// Images fade in by default, if you don't want that | |
Picasso.with(context).load(imageUrl).noFade().into(myImageView); | |
// Explicitly control sizing and scaling | |
Picasso.with(context).load(imageUrl).resize(100, 100).centerCrop().into(myImageView); | |
// Provide placeholder images when downloading and upon error | |
Picasso.with(context).load(imageUrl).placeholder(loadingImage).error(errorImage).into(myImageView); | |
// Load things other than URL based images | |
Picasso.with(context).load(R.drawable.my_res_image).into(myImageView); | |
Picasso.with(context).load(new File(myImageFilePath)).into(myImageView); | |
// Hidden benefits: | |
// | |
// - when an ImageView is re-used (like in an adapter) any previous | |
// download will be cancelled before a new one starts. | |
// | |
// - automatic disk caching using an LRUcache | |
// | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment