How to check if UrlImage is null in Codename One? - codenameone

I am loading image from a URL and it's works as expected.
Scenario when the URL no longer valid, i.e if the image was deleted and I do see the default image displays since I created EncodedImage from the Label icon.
I would like to know if there is anyway I can check if the image has actually loaded from the URL?
What I want to achieve is set a different image to a background if the URL image is not found.
Please advise.
Thank you.

The closest thing is to check if the URLImage's isAnimation() method returns true. If it returns true, then the actual image hasn't been loaded yet. If it returns false, it means that the image is already loaded.

Which system do you use to download the image ? Is the image stocked in the Storage, in the FileSystem ?
If you have dowloaded the image using the ConnectionRequest, you may override it's handleErrorResponseCode method and do something when you have the network error code corresponding to no image ( i.e. 204 : no content).

There are many workarounds for this problem. I use this jQuery one

Related

Filepond : manually revert to default image

I am trying to reset a filepond field to a default image on user action (ie: clicking on a button).
The file could be local or uploaded somewhere (as AWS) it does not matter.
I currently load a default image when the webpage (and therefore the filepond instance / element) is first loaded, so I guess manually calling the load method would do the trick but I can't manage to do that.
I also try with the file-poster plugin, but there is no way to reset the image after it has been deleted.
If you have found a way of doing this or are thinking about something, please let me know :)
Actually #Rik was right, just use addFile function with the option type: "local".

URLImages in list renderer disappearing on iOS

I have a custom list renderer that has a logo for a business in it. It has a label Logo_URLImage that has the placeholder image. In my code I get the data and assign HashMaps to the list model, h.put("Logo_URLImage",imageURL); where imageURL is a string that has the absolute URL to the image.
On Android it seems to always work, but most of the testing has been on iOS devices. What happens is that images are updated as you'd expect the first time or two that you run it. A run later on will show blank images (flash the place holder image and then blank) and once that happens images will never come back.
Any thoughts on what might be causing this?
Check that you defined the LogoName map entry. Check that it is unique per image?
Check that it doesn't include special characters that might cause an issue.

Why isn't get_serving_url() cropping working correctly?

According to the App Engine docs there's a method get_serving_url which gives a URL to an image in the blobstore that can then be resized an cropped. So I can take a URL like:
http://lh4.ggpht.com/TgjDT-cPRr6bjrpSVQeILk93o4Ouzjo1ygMB6KpmnCHhyH5vJKKRrqxCD2bC3T09CRIP6h5QFsV_l0hnhio5bN7z
add =w300-c:
http://lh4.ggpht.com/TgjDT-cPRr6bjrpSVQeILk93o4Ouzjo1ygMB6KpmnCHhyH5vJKKRrqxCD2bC3T09CRIP6h5QFsV_l0hnhio5bN7z=w300-c
and it should turn into a 300x300 square image.
Except, at the time of writing this post, the image that is returned by the 2nd of the above URLs is horribly malformed.
Is this a bug? Or am I doing something wrong?
It's a typo in your url. The documentation says you need to append =sXX-c not =wXX-c.
In your case you need to use the url http://lh4.ggpht.com/TgjDT-cPRr6bjrpSVQeILk93o4Ouzjo1ygMB6KpmnCHhyH5vJKKRrqxCD2bC3T09CRIP6h5QFsV_l0hnhio5bN7z=s300-c

Injecting image content into webkit load

Inside my WebKitGTK+ widget, I want to transparently replace some of the images of an HTML page with different image data I hold in memory.
According to the documentation at http://webkitgtk.org/reference/webkitgtk/stable/webkitgtk-webkitwebview.html#WebKitWebView-resource-request-starting, I've hooked into this signal, which allows the request URI to be changed, but what I really want is to leave it unchanged but generate my own response.
I've tried filling out the WebKitWebResource parameter, and filling out the SoupMessage response from the WebKitNetworkRequest to no avail. Anyone know how to do this?
figured out one way to do it: replacing the request URL with "data:image/jpeg;base64,[inline data]".
Will do for me.

Preview Image while file uploading using "UPLOADIFY"

I am uploading the file using the script from "UPLOADIFY" site, The image is uploading successfully, But Now I want to preview the image on my UI Page, I have written some script (Converted image into Base 64 Encrypted code) to preview the image.
Both the functionalities are working fine individually, But I am unable to execute both functionalities one by one. Here is the code I have used Please help Me.
$(document).ready(function() {
$('#file_upload').uploadify({
'uploader' : '/js/uploadify/uploadify.swf',
'script' : 'index.php',
'fileExt' : '*.jpeg;*.gif;*.png',
'fileDesc' : 'Image Files',
'buttonText' : 'Select File',
'sizeLimit' : 102400,
'onSelect' : function() {preview(this);}
});
});
I'm assuming you would like to preview the image onSelect... That is not possible due to security measures in modern browsers which prevent local (user-local) images from being displayed. This means that in order to preview the image you must first upload it (for example, set the upload mode to 'auto' and then onComplete add the temporary image to a div) and then the user would have a button of some sort to 'confirm' that the temporary image is indeed the desired one. That button would then move the temporary image to a definitive folder and add it to the database.
Sorry for not adding code, but I think you can easily manage to do it on your own. There are some great tutorials around too.
Cheers

Resources