It seems that if at the time when URLImage.createCachedImage is called to load and the image is not available (no connection, etc.), it won't be called again to reload when the connection comes back.
Description:
When the connection is unavailable, it shows a blank image. And it still shows the same blank image when the Display.getInstance().callSerially(...) is called again. It does not seem like it is invoking the connection to try to load the image but the blank image has apparently become the cache.
I'm not sure if I'm describing my problem properly, but here's the simplified question: how to deal with loading of image and handle events when the connection/server is unavailable? (I thought URLImage.createCachedImage knows if the image is not loaded and will try again.)
I have this piece of code to load Image:
protected static final Image loadImage(String imageAccessLocation) {
int filenameIndex = imageAccessLocation.lastIndexOf("/");
String filename = imageAccessLocation.substring(filenameIndex + 1);
String imageAccessBaseLocation = Application.getInstance().getImagesAccessBaseLocation();
String imageAccessURL = imageAccessBaseLocation + imageAccessLocation;
int displayWidth = Display.getInstance().getDisplayWidth();
EncodedImage imagePlaceholder = EncodedImage.createFromImage(Image.createImage(displayWidth, displayWidth / 5, 0xffff0000), true);
Image image = URLImage.createCachedImage(filename, imageAccessURL, imagePlaceholder, FLAG_RESIZE_SCALE);
return image;
}
protected static final Container prepareImageContainer(Item item) {
Image image = item.getImage();
if(image == null) {
return null;
}
Image scaledImage = image.scaled(50, 50);
Container imageContainer = new Container();
imageContainer.add(scaledImage);
return imageContainer;
}
private final void prepare() {
Container imageContainer = prepareImageContainer(lookslike);
Container textContainer = prepareTextDescription(lookslike);
add(imageContainer);
add(textContainer);
}