Automatic memory and disk caching. Featuresadapter DOWNLOADSAdapter re-use is automatically detected and the previous download canceled.
@Override public void GetView (int position, view Convertview, ViewGroup parent) { Squaredimageview View = (squaredimag Eview) Convertview; if (view = = null) { view = new Squaredimageview (context); } String url = getItem (position); Picasso.with (context). Load (URL). into (view);
IMAGE transformationsTransform images to better fit into layouts and to reduce memory size.
Picasso.with (context). load (URL). resize ( ). Centercrop (). into (ImageView)
You can also specify custom transformations for more advanced effects.
public class Cropsquaretransformation implements transformation {@Override public Bitmap transform (Bitmap source) {int size = Math.min (Source.getwidth (), Source.getheight ()); int x = (Source.getwidth ()-size)/2; int y = (source.getheight ()-size)/2; Bitmap result = Bitmap.createbitmap (source, x, y, size, size); if (Result! = Source) {source.recycle (); } return result; } @Override Public String key () {return ' square () ';}}
Pass an instance of this class to the transform
method.
Place holdersPicasso supports both download and error placeholders as optional features.
Picasso.with (context). load (URL). placeholder (r.drawable.user_placeholder) . Error (R.drawable.user_ Placeholder_error) . into (ImageView);
A request would be retried three times before the error placeholder is shown.
RESOURCE LOADINGResources, assets, files, content providers is all supported as image sources.
Picasso.with (context). Load (R.drawable.landing_screen). into (ImageView1); Picasso.with (context). Load (new File (...)). Into (IMAGEVIEW2);
DEBUG indicatorsFor development You can enable the display of a colored ribbon which indicates the image source. Call on the setIndicatorsEnabled(true)
Picasso instance.
The source code to the Picasso, it samples, and this website are available on GitHub.
Maven<dependency> <groupId>com.squareup.picasso</groupId> <artifactid>picasso</ Artifactid> <version>(insert latest version)</version></dependency>
ContributingIf you would a-contribute code you can do so through GitHub by forking the repository and sending a pull request.
When submitting code, * * * Every effort to follow existing conventions and style in order to keep the code as Reada ble as possible. Please also make sure your code compiles by running mvn clean verify
.
Before your code can be accepted to the project you must also sign the individual contributor License Agreement (CLA).
LicenseCopyright Square, inc.licensed under the Apache License, Version 2.0 (the "License"); In compliance with the license.you-obtain a copy of the License at Http://www.apache.org/licenses/LICENSE-2.0Unle SS required by applicable law or agreed to in writing, softwaredistributed under the License are distributed on a "as is" Basis,without warranties or CONDITIONS of any KIND, either express or implied. See the License for the specific language governing permissions andlimitations under the License.