rafa
unread,Jun 4, 2009, 12:56:27 PM6/4/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to J4ME
Hi,
I see no activity for a few months. I just hope the project is still
active. Do you plan any release soon?
Anyway, I have an app, with long menues: about 60 MenuOption, some
of the options' text spreads over 2-3 lines. That made the app slow,
when moving through the menu. Well... I changed a bit the MenuOption
class.
I'm caching the getPreferredSize() result, so I don't call it again
if the text (label) is the same. This is the modified code on
MenuOption.java.
private int[] cachedPreferredTextSize=null; // this variable is new
protected int[] getPreferredTextSize (Theme theme, int viewportWidth,
int viewportHeight)
{
if (null == text.getLabel() || !text.getLabel().equals(getLabel()))
{
text.setLabel( getLabel() );
cachedPreferredTextSize= text.getPreferredSize( theme,
viewportWidth, viewportHeight );
}
return cachedPreferredTextSize;
}
Note that there is a potential error: I'm not checking "theme",
"viewportWidth" and "viewportHeight" being the same as in last call.
In my app that is ok (AFAIK), but you might need to store the values
of those parameters in previous call and compare to make it fool
proof.
Hope it is usefull for someone (and is added to next release)
Regards,
Rafa