Note that there are some explanatory texts on larger screens.

plurals
  1. POUse of Target in Picasso on Adapter
    text
    copied!<p>Im having big troubles using a Target inside an adapter. Im confused about the documentation on the code</p> <blockquote> <p>Objects implementing this class <strong>must</strong> have a working implementation of {@link #equals(Object)} and {@link #hashCode()} for proper storage internally. Instances of this interface will also be compared to determine if view recycling is occurring. It is recommended that you add this interface directly on to a custom view type when using in an adapter to ensure correct recycling behavior.</p> </blockquote> <p>Im trying to use the Target in this way: </p> <pre><code>class CustomTarget implements Target { private ImageView imageView; public CustomTarget(ImageView imageView) { this.imageView = imageView; } @Override public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) { imageView.setImageDrawable(new RoundedAvatarDrawable(bitmap)); } @Override public void onBitmapFailed(Drawable errorDrawable) { imageView.setImageDrawable(errorDrawable); } @Override public void onPrepareLoad(Drawable placeHolderDrawable) { imageView.setImageDrawable(placeHolderDrawable); } @Override public boolean equals(Object o) { return imageView.equals(o); } @Override public int hashCode() { return imageView.hashCode(); } } @Override public View getView(int position, View v, ViewGroup parent) { .... RoundedAvatarDrawable r = new RoundedAvatarDrawable(BitmapFactory.decodeResource(mContext.getResources(), R.drawable.ic_avatar_seahorse)); ImageCacheController.with(mContext).getPicasso().load(member.getPicture_url()).resize(100, 100).centerCrop().placeholder(r).error(r).into(new CustomTarget(viewHolder.ivAvatar)); .... } </code></pre> <p>It's doesn't work and the images change between each others randomly </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload