Fork us on GitHub

JSON, Overscroll & More

Its been pretty busy around here the last couple of weeks. Ho...

JSON, Overscroll & More

Its been pretty busy around here the last couple of weeks. However, we still introduced a couple of new API's and abilities besides the many bug fixes that constantly go in.
We deprecated JSONParser.parse(Reader) in favor of Map<String, Object> parseJSON(Reader i). This is effectively the exact same class with one minor difference, it returns HashMaps/ArrayLists rather than Hashtables/Vectors to represent the hierarchy. Besides the modern aspect of the new collections they are also slightly faster due to the lack of synchronization calls.

We finally implemented RFE 738 which asks for improved overscroll behavior, we can't get it to be 100% accurate but we got it as close as possible with the current rendering architecture.

With MultiList/GenenricListCellRenderer one of the common issues is making a UI where a specific component within the list renderer has a different UIID style. E.g. this can be helpful to mark a label within the list as red, for instance in cases of a list of monetary transactions. Up until now the only answer we had was: you need to create your own renderer. With the latest version of GenericListCellRenderer (MultiList uses GenericListCellRenderer internally) we have another option.

Normally to build the model for a renderer of this type we use something like:
map.put("componentName", "Component Value");

What if we want
componentName to be red? Just use:
map.put("componentName_uiid", "red");

This will apply the uiid "red" to the component which you can then style in the them. Notice that once you start doing this you need to define this entry for all entries e.g.:
map.put("componentName_uiid", "blue");

Otherwise the component will stay red for the next entry (since renderer acts like a rubber stamp ).

Last but not least we felt the need to simplify the very common task of download. Up until now downloading a file required a bit of code, where you needed to open a connection request and do quite a few other things. There is really no justification for that.
So we added to Util the following methods: downloadUrlToFileSystemInBackground, downloadUrlToStorageInBackground, downloadUrlToFile & downloadUrlToStorage.
These all delegate to a new feature we added to ConnectionRequest called:  ConnectionRequest.setDestinationStorage(fileName)/

Which simplifies the whole process of downloading a file.

Notice: This post was automatically converted using a script from an older blogging system. Some elements might not have come out as intended.... If that is the case please let us know via the comments section below.

Share this Post:

Posted by Shai Almog

Shai is the co-founder of Codename One. He's been a professional programmer for over 25 years. During that time he has worked with dozens of companies including Sun Microsystems.
For more follow Shai on Twitter & github.