3

I have used Picasso for loading images in my Gallery page with Recyclerview and load images from Server. It works great on all devices good,except Samsung S4 device.In S4 device the images are corrupted and it displays some horizontal lines on all images.What is the problem in my code.Also I think on same S4 device it works fine before updating my supports library versions from 22.2.1 to 23.3.0.

GalleryAdapter.java

@Override
        public void onBindViewHolder(GalleryViewHolder galleryViewHolder, final int position) {

            // Load images from Assets using Picasso library.
            Picasso picasso = Picasso.with(context);

            //picasso.setLoggingEnabled(true);
            //picasso.setIndicatorsEnabled(true);

            if(AppUtilities.isNetworkConnected(context)){
                picasso.load(imagesArrayList.get(position).getUrl())
                        .placeholder(android.R.color.darker_gray)
                        .fit()
                        .centerCrop()
                        .memoryPolicy(MemoryPolicy.NO_CACHE)
                        .networkPolicy(NetworkPolicy.NO_CACHE)
                        .into(galleryViewHolder.galleryImageView);
            }
            else{
                picasso.load(imagesArrayList.get(position).getUrl())
                        .placeholder(android.R.color.darker_gray)
                        .fit()
                        .centerCrop()
                        .into(galleryViewHolder.galleryImageView);
            }
    }

    public class GalleryViewHolder extends RecyclerView.ViewHolder {

            protected ImageView galleryImageView;

            public GalleryViewHolder(View itemView) {
                super(itemView);
                this.galleryImageView = (ImageView) itemView.findViewById(R.id.gallery_imageview);
            }
        }
Ramprasad
  • 7,981
  • 20
  • 74
  • 135
  • I think there is a problem in your _if..else..._ condition. Just print a log in both condition. I think both may be executed. – Piyush May 26 '16 at 05:00
  • @PiyushGupta This is issue occurs even there is no if else code. It occurs even if put else case code alone. – Ramprasad May 26 '16 at 05:04
  • Try to use another placeholder – Piyush May 26 '16 at 05:10
  • As your code looks fine, I recommend digging through the [issues](https://github.com/square/picasso/issues) from the library and finally open one by yourself if you found nothing. :) – yennsarah May 26 '16 at 06:16

1 Answers1

0

Try this, before setting the image just set it to null like this:

galleryViewHolder.galleryImageView.setImageDrawable(null);
Nongthonbam Tonthoi
  • 12,667
  • 7
  • 37
  • 64