Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.maryanovsky.gwtutils.client.ui
Class ImageLoadingManager

    java.lang.Object
      com.maryanovsky.gwtutils.client.ui.ImageLoadingManager

    public class ImageLoadingManager

extends Object

Implements a queue of images to be loaded by the browser. This is needed because some browsers (*cough* Internet Explorer *cough*) break when asked to load many images and then cancel loading some (the breakage manifests in the network hanging for a few minutes). This class carefully manages the process of loading the images, never feeding the browser too many, and cancelling downloads carefully so as to avoid the browser breaking.

Note that the behaviour of this class might differ from that of a perfectly behaving browser if you simply use an Image object for each image you wish to download. For example, a browser knows whether a certain image is already in the cache, and so, attempting to load it, will return the result immediately. This class, however, if the loading slots are full, will put the image into a queue regardless of its caching status, and will only handle it when all the images in front of it have been handled. Because some of them may not be cached, it may take a while until that occurs.

Author:
  Maryanovsky Alexander

Constructor Summary
`ImageLoadingManager()`

Method Summary
`static void` | `cancel(String url, ImageLoadListener listener)` Removes the specified url from the loading queue.
`static void` | `load(String url, ImageLoadListener listener)` Adds an image to be loaded, and notify the specified `ImageLoadListener` of the loading status.
`static void` | `onImageAbort(String url, JavaScriptObject image)` Invoked when the loading of the image was aborted.
`static void` | `onImageError(String url, JavaScriptObject image)` Invoked when the image errors while loading.
`static void` | `onImageLoad(String url, JavaScriptObject image)` Invoked when the image finishes loading normally.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ImageLoadingManager

    public ImageLoadingManager()

Method Detail

### load

    public static void load(String url,
                            ImageLoadListener listener)

  Adds an image to be loaded, and notify the specified `ImageLoadListener` of the loading status. Note that, for cached images, the listener may be called right from within the call to `load`.

### cancel

    public static void cancel(String url,
                              ImageLoadListener listener)

  Removes the specified url from the loading queue. Note that if the image is already being downloaded, it will continue being downloaded, but transparently, to the caller of this method, that is, the listener will not be called when the image is done loading.

### onImageLoad

    public static void onImageLoad(String url,
                                   JavaScriptObject image)

  Invoked when the image finishes loading normally.

### onImageError

    public static void onImageError(String url,
                                    JavaScriptObject image)

  Invoked when the image errors while loading.

### onImageAbort

    public static void onImageAbort(String url,
                                    JavaScriptObject image)

  Invoked when the loading of the image was aborted.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD