1

I'm using 2.3.3 and everything seems to be working fine except in my custom ListView. Most of the time, Picasso loads my images perfectly fine, but there are a few occasions where the image never loads and the spinner continues spinning. Additionally, sometimes the loading spinner will be present with the image loaded behind it with some opacity set (don't have a screenshot of this yet, but I'll try to grab one).

Here's how I'm loading my images in my ArrayAdapter:

Picasso picasso = new Picasso.Builder(getContext()).listener(
new Listener() {
        @Override
         public void onImageLoadFailed(Picasso arg0,
                                Uri arg1, Throwable arg2) {
                   if (Constants.debug) Log.i(LOG_TAG, "imageloadfailed");
                   arg2.printStackTrace();          
         }
        }).debugging(true).build(); 

picasso.load(imgUrl).placeholder(R.id.progress).into(h.picture, new Callback() {
        @Override
        public void onError() {
              if (Constants.debug) Log.i(LOG_TAG, "error");
        }

        @Override
        public void onSuccess() {
              if (Constants.debug) Log.i(LOG_TAG, "success");
        }
});

Relevant XML portion:

    <!-- Image -->
    <RelativeLayout
    android:id="@+id/plist_image_container"
    android:layout_gravity="center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

        <ProgressBar                
            android:id="@+id/progress"
            android:layout_width="40dp"       
            android:layout_height="40dp"
            android:layout_centerInParent="true"/>

        <ImageView
           android:id="@+id/plist_item_thumb"
           android:adjustViewBounds="true"
           android:scaleType="fitCenter"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:gravity="center"/>           
   </RelativeLayout>

I'm never getting to the onImageLoadFailed(....), and the images never load despite waiting a fair amount of time on a good network.

Here's an example of an image I'm trying to load: http://res.cloudinary.com/spotlight-images/image/upload/v1408387652/IMG_1408387652509.jpg

Edit: I recently switch from AQuery to Picasso, and this problem did not occur with AQuery.

ynnadkrap
  • 258
  • 2
  • 11

2 Answers2

0

Check answer from this link

Use these methods as suggested in the answer

onSuccess() {...}
onError() {...}

Check this link for callback

Community
  • 1
  • 1
Paritosh
  • 2,097
  • 3
  • 30
  • 42
  • onError is never invoked. onSuccess() is always called even when the image doesn't display. – ynnadkrap Aug 19 '14 at 14:43
  • Can you add some more code so that I can test it on my machine – Paritosh Aug 19 '14 at 14:50
  • The codebase is fairly extensive, so I'm not going to post all of it. But Picasso is being called inside of a custom ArrayAdapter<> as shown above. I'll edit the OP to show the relevant part of the XML. – ynnadkrap Aug 19 '14 at 14:57
0
Picasso.with(getContext())
    .load(url)
    .into(imageView, new com.squareup.picasso.Callback() {
        @Override
        public void onSuccess() {

        }

        @Override
        public void onError() {

        }
    });

check this code it might help you...

SumeetP
  • 109
  • 1
  • 2