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

Add source of image to onLoadingComplete callback #239

Closed
tamir7 opened this issue Apr 8, 2013 · 3 comments
Closed

Add source of image to onLoadingComplete callback #239

tamir7 opened this issue Apr 8, 2013 · 3 comments
Labels

Comments

@tamir7
Copy link

tamir7 commented Apr 8, 2013

Greetings,

I have an endless grid view with images from the web, I also have a custom animation that I play on image load. My problem is with the fact that in onLoadingComplete, I don't know if the image was loaded from cache or from the web. So the animation plays every time I scroll, which makes my grid view look bad.

I've seen your solution in ImageListActivity, but holding a static list of url's in the listener seems like a hack to me.

A very simple solution would be to extend onLoadingComplete to:

enum ImageSource {
Network,
MemoryCache,
DiscCache
};
void onLoadingComplete(String imageUri, View view, Bitmap loadedImage, ImageSource source);

What do you think?

@nostra13
Copy link
Owner

I had the similar idea - #149
But I think solution in ImageLiastActivity is enough. Why do you think ii seems a hack? It's not necessary to keep static list, make it non-static.

@tamir7
Copy link
Author

tamir7 commented Apr 10, 2013

Its a hack because it does not really tell you which items are cached and witch are not.
Here are 2 scenarios that will break that solution:

  1. I've created a limited cache, and one of the images has been evicted, but I still have it in my list, so now I'm not playing an animation.
  2. The other way around. I have the image in the cache, but my application was killed by Android (lets say I got a call, and Android needed the memory), I've returned to my app, but my list is empty, and I'm playing animation on every image in my grid view. (You might fix that by saving the list in SaveInstanceState but that's just unnecessary overhead to my mind.)

Also, that solution does not distinguish between memory cache and disc cache.

@stabones
Copy link

Something like this would be nice, by why not take it a step further. I feel that you should return the STREAM, instead of a bitmap. That way you can use BitmapRegionDecoder on the cached file and not worry about having to hold all of image in RAM like the current loadedImage is!

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

No branches or pull requests

3 participants