I see in the samples that to trigger an event from a “non-MyCanvas” thread, I have to use something like
How would I trigger an event from inside the “MyCanvas” thread? I would like to close an alert dialog and do a transition (back) but have the problem that the alert dialog is handled in one listener and the back button is handled in a different listener.
My sample: I go from Login View (default nUIEventListener) → Inbox View (default nUIEventListener) → Details (second nUIEventListener).
I tried the following:
nUIButtonElement dummyBackBtn = new nUIButtonElement(NUIID_BACK_BUTTON, “Back”);
This works in Android (not in Phoney though), but after that, the back button from the “Inbox View” reacts as the back button from the “Details”.
I might be misunderstanding, but why don’t you just queue a custom event on the alert dialog that dismisses and kicks off the transition? Ie: nUIController.eventListenerQueue (alert_dialog, CUSTOM_EVENT_0);
The transitionFrom call you are making will potentially set up things like back buttons, etc. so that when you create your dummy button as the back button it overrides the previous back button that was set up by transitionFrom, if that makes sense. If your idea is to transition from your Details View (that has the alert dialog on top of it) back to the Inbox View I am pretty sure you can just .transitionFrom (pop_up_dialog) and then either trigger the back button that was defined for the Details View or skip the event queue processing for back and directly transitionToView(inbox_view).
One thing you can keep in mind is that you should be getting EVT_TRANSITION_FROM_COMPLETE on an element (say a popup dialog) when a transition finishes, so you can then queue events after that.
That is exactly what I am doing right now. First transitionFrom the pop_up_dialog and then transitionToView (inside the handling for the back button). This works fine in iOS, but not in Android, where the back button from the Inbox acts as the back button from the Details.
But your hint on the EVT_TRANSITION_FROM_COMPLETE is a good one to follow, since it is probably the safest way to do what I want. I’ll give it a try and see how it works.