2

I am displaying images in gridView, using this code:-

 Picasso.get().load(wallpaperInfo.getThumbPicUrl()).fit().into(imgView);

which works perfectly fine. I have onItemClickListener()on my gridView, which takes me to another activity, where I am displaying Image and loading it from URL again.

Picasso.get().load(wallpaper.getPicUrl()).into(new Target() {
    @Override
    public void onBitmapLoaded(Bitmap bitmapS, Picasso.LoadedFrom from) {
        bitmap = bitmapS;
        imageView.setImageBitmap(bitmap);
        onLoadImageData();
        progressBar.setVisibility(View.GONE);
    }

    @Override
    public void onBitmapFailed(Exception e, Drawable errorDrawable) {

    }

    @Override
    public void onPrepareLoad(Drawable placeHolderDrawable) {
        progressBar.setVisibility(View.VISIBLE);
    }
});

Now problem is some images get load and some not. (I think big images are not loding) but after I click back and press on my gridView Item again, Image Loads! Where I am going wrong or What I dont know??

My Picasso Logs:-

D/Picasso: Hunter      decoded      [R7]+1557ms 
04-04 00:37:12.922 14080-14461/we_pirate.one.com.opw D/Picasso: Dispatcher  batched      [R7]+1562ms for completion
04-04 00:37:12.950 14080-14080/we_pirate.one.com.opw D/Picasso: Main        canceled     [R7]+1590ms target got garbage collected
04-04 00:37:13.132 14080-14461/we_pirate.one.com.opw D/Picasso: Dispatcher  delivered    [R7]+1769ms 
04-04 00:37:13.134 14080-14080/we_pirate.one.com.opw D/Picasso: Main        completed    [R7]+1769ms from DISK
user6556461
  • 377
  • 3
  • 14

1 Answers1

0

Please check the version that you are using first, after this remove the .fit()

Like here

Bea
  • 16
  • 3
  • my gridView Item is loading fine and it has fixed height and width. My view in other activity is not loading where I am not using fit() – user6556461 Apr 03 '18 at 18:58
  • did you tried to use .setLoggingEnabled(true) to see the error? – Bea Apr 03 '18 at 19:01
  • Please check the question again, I have added logs now. – user6556461 Apr 03 '18 at 19:08
  • It looks like it's being garbage collected. I saw a solution for this in gitHub. Can you try implement it on a view or store it in a non-local field? – Bea Apr 03 '18 at 19:23
  • I found the solution bea thanks.. Actually I need to instantiate Target explicitly and give a tag to view – user6556461 Apr 03 '18 at 19:35