Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CallBack.onSuccess() never called when image loaded from cache #1140

Closed
atomass opened this issue Sep 16, 2015 · 4 comments
Closed

CallBack.onSuccess() never called when image loaded from cache #1140

atomass opened this issue Sep 16, 2015 · 4 comments

Comments

@atomass
Copy link

atomass commented Sep 16, 2015

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

@JakeWharton
Copy link
Member

Show code.

@atomass
Copy link
Author

atomass commented Sep 16, 2015

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.

@atomass
Copy link
Author

atomass commented Sep 16, 2015

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

@atomass atomass closed this as completed Sep 16, 2015
@crearo
Copy link

crearo commented May 9, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants