问题
My app written with Codename One involves showing a camera preview In a main form. I have used the native interface implementation to make it work on Android (iOS later).
The app also includes in app purchase to upgrade to full version. That's why a form is shown regularly to suggest the user to upgrade. They can also choose to upgrade later which causes this upgrade to full version form to disappear and make the main form with the camera preview to appear.
Yet on real devices sometimes the upgrade to full version form does not completely disappears and there are reminiscences of it on the main form. In that case the camera preview is displayed on part of the screen and the app buttons do not show. However after some seconds if the user touch the screen the main form gets completely shown and the reminiscence of upgrade form are gone.
It looks like there may be too much things done on the UI thread but I am just calling new MainForm(theme).show()
when the user hits the button to close the upgrade form. So this should be OK shouldn't it? Please note that the CN1 simulator does not show edt violation (but there is no camera preview in the simulator).
Or do I have to call revalidate () in the MainForm after adding the components into the layout ? What should I do actually to make these reminiscences disappear ?
Any help really appreciated,
回答1:
These things are always hard to track but I'm guessing the peer component collides in some way with the new form.
Make sure you don't call postInvalidate
unless you really have to and even then you should generally limit and avoid it when possible as it might conflict with our drawing logic.
Also make sure you didn't change the opacity of the parent forms e.g. if you changed the form UIID.
回答2:
It looks like the solution has been found. Indeed I had a native method that initialized the camera and the surfaceview. I was running this method on the EDT and then showing the new MainForm.
Indeed I embraced the initialization method in an invokeAndBlock()
block. Now it looks like the kind of lag is far less visible (I could not see it). In my own logic I can explain it with the fact that the invokeAndBlock()
will do the initialization job on a separate thread and when it's fully ready (so the camera and surfaceview are ready to be shown), the MainForm can be shown.
Could it be the actual solution @Shai ?
来源:https://stackoverflow.com/questions/40902880/previous-form-does-not-completely-disappears-on-codename-one