Last active
May 20, 2019 10:19
-
-
Save jerrellmardis/5687856 to your computer and use it in GitHub Desktop.
A simple example illustrating how to use Picasso to load a bitmap into a Target. https://github.com/square/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.with(context).load(url).into(new Target() { | |
@Override | |
public void onSuccess(Bitmap bitmap) { | |
holder.image.setImageBitmap(bitmap); | |
} | |
@Override | |
public void onError() { | |
// handle | |
} | |
}); |
Target
will be garbage collected in this case, since Picasso holds a WeakReference
to it. Its better to create a data member to hold the reference and not lose it with gc.
@kartikarora, Can you help me?
I used to your suggestions, it is good for me.
But, when I have used target in an adapter of Recycler View, this target didn't work in the second element of Recycler View.
Do you have any suggestion for me in this case?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Methods changed in v2.0.0: