Multiple Ui.Confirmations, display issues?

I am making a custom workout app (one can build his/her own workout by entering up to 16 text in the form of Squats_3x20 for 3 reps of 20 squats, or Squats_45s for 45 seconds of squats, etc).

Anyway, I am using a menu when the user is in a workout and presses the menu button to let the user choose to resume or abort activity. When aborting I use a Ui.confirmation to confirm the selection and after that if there is an activity to be saved another Ui.confirmation to allow the user to save the activity.

The menu displays fine, I select 'abort' and the stop-confirmation shows, I confirm it and the save-confirmation comes up but then the stop and save-confirmations seems to be overlapping eachother.

The Save title is shown shortly, then the stop title again. If I confirm stop again I get the save confirm shortly but this goes back to the stop-confirm right away... etc

Pressing back (lap) i seem to be able to get back to the menu, but can't figure out how ti fix this.

Tried manually calling popView but this seems to mess with popview being called by the Ui.Confirmation and results in for example the mainview being popped or stuff like that.

Basically, is this expected behavior and how can I best handle this?

I am thinking about just cancelling the confirm on stop, but would like to know if there is something I have to take into account...

(I realize the post is a bit vague, hope it's kinda clear though)
  • Have you tried popping the view before you push a new one?
  • Yeah, I did. But then somehow both views get popped... It seems the second confrimation dialog is automatically popped or something.

    I added a demo project which shows what I mean (Think that's a lot clearer then my story above ;) ).

    https://surfdrive.surf.nl/files/index.php/s/xDAomgT9KRDqLU4

    (Couldn't add the .zip as attachment?)

    Reproducing the issue:

    1. Run app
    2. Hold menu button to show menu
    3. Choose top item ("Show confirm1")
    4. The first confirmation shows fine, press the start button to confirm (this will show the 2nd confirmation)
    5. The second confirmation (confirm_2) is displayed VERY briefly (say 1 second) and then confirm_1 is shown right away again.
    repeat step 4 and 5 to reproduce the issue again and again ;)
    6. Pressing back takes you back to the main menu

    I tried adding popView in several places but it seems it's not working (it always seem to result in the confirm_1 to be popped)

    So yeah, no clue... Tried creating a custom confirmation dialog extending Ui.View but not much luck there either but that could be due to the fact I still struggle with ConnectIQ in general. Still, would be nice to be able to simply use the default options...
  • Hi FlipStone

    I'm not sure if this is related to you problem, but hopefully it can help.

    Normally there is an implicit call to Ui.popView() at the end of onMenuItem(). This pops the menu after some 'normal' action. If you make another call to Ui.popView(), there'll be two Ui.popView()'s in the queue, and the second one would pop the view which is previously being shown.

    Exception: if a view is pushed inside the context of onMenuItem() this implicit call to Ui.popView() is NOT made. This is how menus get superposed. If you don't want to superpose, you can add the Ui.popView() just before the new push. In you example, I would do that before you push the first confirmation dialog.

    More information on this:
    https://forums.garmin.com/forum/developers/connect-iq/1330722-ui-popview-to-avoid-superposing-menus

    Maybe the confirmation dialog works in a similar way. Because you push another confirmation dialog on its delegate, the first one is not popped. Try adding a Ui.popView() just before the new push.

    Let us know if it helps ;-D

    Cheers!
  • Thanks r.485, I am going to be looking into it tomorrow! Appreciate the info and tips ;)