1
votes

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.

2
have u solved this problem? if u do please post an answer - Kaushik
I did not. I ended up switching to Volley, and everything has been working fine. - ynnadkrap

2 Answers

0
votes

Check answer from this link

Use these methods as suggested in the answer

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

Check this link for callback

0
votes
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...