When you have so many features as Codename One has things sometimes slip, a feature gets lost and even the guys who created it forget it was there. There are two such stories in this post one dates back to the very start of Codename One....
But first lets start with the other one. A month or so ago we added a component called SpanButton which has been requested by developers for quite a while. This is effectively a button that can break lines like a text area, its really a Lead Component internally (but that's another post).
However, someone (me) forgot to make the class public before committing and we just didn't notice that.
I n the release we made today the class is both public and it is also in the designer tool so you can just drag it into place just like any other button.
It has features and behaviors similar to MultiButton since it too is a lead component based composite.
The CachedDataService is one of those services we added ages ago because we thought its important to have, then completely forgot about it. As it happens we forgot to write about it and so no one really used it to any extent (since it didn't work). These past two weeks a developer on the forum (Fabrice Kabongo) drew my attention to the fact that this class doesn't work and also provided helpful suggestions for fixes, I wrote it yet didn't even recall its purpose.
This is a shame since the class is actually pretty useful and its possible we should update our internal code to use it E.g. say you have an image stored locally as image X. Normally the ImageDownloadService will never check for update if it has a local cache of the image. This isn't a bad thing, its pretty efficient.
However, it might be important to update the image if it changed but you don't want to fetch the whole thing...
The cached data service will fetch data if it isn't cached locally and cache it. When you "refresh" it will send a special HTTP request that will only send back the data if it has been updated since the last refresh.
Image copyright: Inspiration in a box
Using Helvetica on iOS
Chen was dealing with some designers this week and was facing requirements to incorporate Helvetica derivatives into an iOS application. Normally we allow developers to just embed a TTF into the application
and it "just works" but Helvetica is builtin to iOS and shouldn't be used on other platforms (due to copyrights). So how do you use a font such as HelveticaNeue?
Simple: Font helveticaNeue = Font.createTrueTypeFont("HelveticaNeue", null);
This will "just work" even though the TTF file name is null it will just search the system. Notice that it will crash if the font doesn't exist so use it carefully!
To get a specific size in pixels e.g. 14p just go with: Font fontNeue14 = helveticaNeue.derive(14, Font.STYLE_PLAIN);
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.