Last active
August 29, 2015 13:57
-
-
Save mberberoglu/9510613 to your computer and use it in GitHub Desktop.
Picasso Android
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.with(context).load("http://mustafab.net/images/captain.png").into(imageView); |
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
//Resim kesme işlemi | |
Picasso.with(context) | |
.load(url) | |
.resize(50, 50) | |
.centerCrop() | |
.into(imageView); | |
//Custom resim manipilasyonu | |
Picasso.with(context) | |
.load(url) | |
.transform(new Transformation() { | |
@Override | |
public Bitmap transform(Bitmap bitmap) { | |
int size = Math.min(bitmap.getWidth(), bitmap.getHeight()); | |
int x = (bitmap.getWidth() - size) / 2; | |
int y = (bitmap.getHeight() - size) / 2; | |
Bitmap result = Bitmap.createBitmap(bitmap, x, y, size, size); | |
if (result != bitmap) { | |
bitmap.recycle(); | |
} | |
return result; | |
} | |
@Override | |
public String key() { | |
return null; | |
} | |
}) | |
.into(imageView); | |
//Öntanımlı view atama ve hata durumlari için view atama | |
Picasso.with(context) | |
.load(url) | |
.placeholder(R.drawable.user_placeholder) | |
.error(R.drawable.user_placeholder_error) | |
.into(imageView); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment