Picasso: CallBack.onSuccess() never called when image loaded from cache

Created on 16 Sep 2015  路  4Comments  路  Source: square/picasso

Hi, as the title states neither CallBack.onSuccess() nor CallBack.onError() are called when Picasso load an image from the cache. So how it is possible to know when the image is loaded?

Thanks in advance

Most helpful comment

I've figured it out. I'm very sorry the onSuccess is called correctly each time. The difference is that, when the image is already in the memory, the call is synchronous and this behavior messed up some of my app logic.
I'm orry for wasting your time.
Closing...

All 4 comments

Show code.

Sorry, the code is so simple that I've not thought of posting it

String url = "http://www.example.com/foo.png";
ImageView imgView = ....;
Picasso.with(getActivity()).load(url).placeholder(R.drawable.court).into(imgView, new Callback() {
            @Override
            public void onSuccess() {
                Log.e(TAG, "onSuccess()");
            }

            @Override
            public void onError() {
                Log.e(TAG, "Picasso error!!");
            }
        });

onSuccess() is called only when the image is downloaded from the network.

I've figured it out. I'm very sorry the onSuccess is called correctly each time. The difference is that, when the image is already in the memory, the call is synchronous and this behavior messed up some of my app logic.
I'm orry for wasting your time.
Closing...

Thanks a lot for this! I didn't realise this was called synchronously if cached - messed up my app logic too :D

Was this page helpful?
0 / 5 - 0 ratings