1010import com .codename1 .ui .Label ;
1111import com .codename1 .ui .layouts .BorderLayout ;
1212import com .codename1 .ui .layouts .BoxLayout ;
13+ import com .codename1 .ui .CN ;
1314
1415import com .codenameone .examples .hellocodenameone .tests .Cn1ssDeviceRunner ;
1516import com .codenameone .examples .hellocodenameone .tests .Cn1ssDeviceRunnerReporter ;
@@ -30,9 +31,9 @@ public void start() {
3031 }
3132 if (!deviceRunnerExecuted ) {
3233 deviceRunnerExecuted = true ;
33- new Cn1ssDeviceRunner ().runSuite ();
34+ CN . callSerially (() -> new Cn1ssDeviceRunner ().runSuite () );
3435 }
35- showMainForm ();
36+ new Form ( "Fallback" ). show ();
3637 }
3738
3839 public void stop () {
@@ -42,59 +43,4 @@ public void stop() {
4243 public void destroy () {
4344 // Nothing to clean up for this sample
4445 }
45-
46- private void showMainForm () {
47- if (mainForm == null ) {
48- mainForm = new Form ("Main Screen" , new BorderLayout ());
49-
50- Container content = new Container (BoxLayout .y ());
51- content .getAllStyles ().setBgColor (0x1f2937 );
52- content .getAllStyles ().setBgTransparency (255 );
53- content .getAllStyles ().setPadding (6 , 6 , 6 , 6 );
54- content .getAllStyles ().setFgColor (0xf9fafb );
55-
56- Label heading = new Label ("Hello Codename One" );
57- heading .getAllStyles ().setFgColor (0x38bdf8 );
58- heading .getAllStyles ().setMargin (0 , 4 , 0 , 0 );
59-
60- Label body = new Label ("Instrumentation main activity preview" );
61- body .getAllStyles ().setFgColor (0xf9fafb );
62-
63- Button openBrowser = new Button ("Open Browser Screen" );
64- openBrowser .addActionListener (evt -> showBrowserForm ());
65-
66- content .add (heading );
67- content .add (body );
68- content .add (openBrowser );
69-
70- mainForm .add (BorderLayout .CENTER , content );
71- }
72- current = mainForm ;
73- mainForm .show ();
74- }
75-
76- private void showBrowserForm () {
77- Form browserForm = new Form ("Browser Screen" , new BorderLayout ());
78-
79- BrowserComponent browser = new BrowserComponent ();
80- browser .setPage (buildBrowserHtml (), null );
81- browserForm .add (BorderLayout .CENTER , browser );
82- browserForm .getToolbar ().addMaterialCommandToLeftBar (
83- "Back" ,
84- FontImage .MATERIAL_ARROW_BACK ,
85- evt -> showMainForm ()
86- );
87-
88- current = browserForm ;
89- browserForm .show ();
90- }
91-
92- private String buildBrowserHtml () {
93- return "<html><head><meta charset='utf-8'/>"
94- + "<style>body{margin:0;font-family:sans-serif;background:#0e1116;color:#f3f4f6;}"
95- + ".container{padding:24px;text-align:center;}h1{font-size:24px;margin-bottom:12px;}"
96- + "p{font-size:16px;line-height:1.4;}span{color:#4cc9f0;}</style></head>"
97- + "<body><div class='container'><h1>Codename One</h1>"
98- + "<p>BrowserComponent <span>instrumentation</span> test content.</p></div></body></html>" ;
99- }
10046}
0 commit comments