Cache a form?

12 views
Skip to first unread message

Gareth Murfin

unread,
Mar 5, 2019, 10:18:31 AM3/5/19
to CodenameOne Discussions
The set up time for some of my screens takes almost 1 second, so app seems unresponsive, I was wondering, is there any way to cache a form? So it doesnt have to "build" every time, and do all my logic? Can we store a finished form and use that to speed up the app? 

I guess in a way this is kind of like onResume in Android, only onCreate does the hard work, and only gets called first time its made. 

Shai Almog

unread,
Mar 5, 2019, 10:58:07 PM3/5/19
to CodenameOne Discussions
start() literally caches the last Form. You don't need to throw away the Form objects.

Gareth Murfin

unread,
Mar 28, 2019, 10:05:25 AM3/28/19
to CodenameOne Discussions
Thanks, I tried to cache some forms but it didnt seem to keep the complete form. 

For example once I have set up the UI and then populated it, I call this in postShow():

cachedForm=getCurrentForm(); 

then if I come back to the form I do 

if (cachedForm!=null)
        {  
            cachedForm.show();
            return;
        }

this works but it does not show the changes I made to the form, for example most of my forms are full of empty containers, at run time I use createContainer to swap in various things I have designed in the gui editor, but none of them appear on the cached form.

Did I do it wrong somehow ? 

Shai Almog

unread,
Mar 28, 2019, 11:19:00 PM3/28/19
to CodenameOne Discussions
Are you using the old GUI builder?
It's a bit problematic to cache forms in the old GUI builder.
Reply all
Reply to author
Forward
0 new messages