poptanimukesh / google-web-toolkit-incubator

Automatically exported from code.google.com/p/google-web-toolkit-incubator
0 stars 0 forks source link

ImageLoader has no way to detect when the load has completed and failed to find some URIs #338

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Using the latest gwt-incubator with GWT 2.0.1 - I don't see any way to find out 
if the ImageLoader fails to find some images; as the callback is not 
invoked.

e.g. imagine this code...

            String[] dummyUris = {"dummy.jpg"};
            ImageLoader.loadImages(dummyUris, new ImageLoader.CallBack() {
                public void onImagesLoaded(ImageElement[] imageElements) {
                    System.out.println("This will never be called!");
                }
            });

since the "dummy.jpg" does not exist, the callback is never invoked so there's 
no way to know if it was loaded or not. Should there be some kind of extra 
method on ImageLoader.Callback to indicate that the entire request has 
completed, so if no onImagesLoaded() methods are invoked you know things 
failed?

Since the code might do some async loading, its a bit scary to just assume 
after the loadimages() method returns that things have completed.

Maybe the API needs a little work so its easier to see what images were loaded 
and what were not?

Or maybe the array just contains null elements for URIs that could not be 
found? Then the API doesn't change (other than null elements in the array when 
things can't be found?). Then if you are trying to load 10 images and one 
fails, you can spot which elements in the array map to what URIs - and which 
one 
failed, by just using null checks?

Original issue reported on code.google.com by james.st...@gmail.com on 15 Feb 2010 at 4:31