|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.maryanovsky.gwtutils.client.ui.ImageLoadingManager
public class ImageLoadingManager
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.
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(JavaScriptObject image)
Invoked when the loading of the image was aborted. |
static void |
onImageError(JavaScriptObject image)
Invoked when the image errors while loading. |
static void |
onImageLoad(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 |
---|
public ImageLoadingManager()
Method Detail |
---|
public static void load(String url, ImageLoadListener listener)
ImageLoadListener
of the loading status. Note that, for
cached images, the listener may be called right from within the call to
load
.
public static void cancel(String url, ImageLoadListener listener)
public static void onImageLoad(JavaScriptObject image)
public static void onImageError(JavaScriptObject image)
public static void onImageAbort(JavaScriptObject image)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |