Menu2 question

Hi, 

In menu2inputdelegate there is an onselect method. But this only triggers code if someone really selects that menuitem.

I am looking for a way to put code behind the event that a menuitem is shown on screen for the 1st time... 

Is there a way to do that? 

(Use Case: I am author of the garmoticz plugin which is basically a frontend for domoticz. So the menu should show all devices and if the device is shown in the menu i'd like it to refresh te status, but only for that specific device to prevent too many url calls)

  • That’s indeed exactly the issue. I did fix it now by downloaden all data at once, but that only works on newer devices. Onder devices don’t accept the large http requests and give -402 or -403 errors on the webrequest method 

    i also tried working around this by doing a lot of small http requests but then on old devices it becomes wat too slow because of all the processing. 

    so best solution would be downloading only the data that is needed to display the menu items on screen

  • Yes, but until that will happen (I mean that Garmin add support for that) you can improve the code slightly with some jungling (if you know which devices are old/new), then you can make it work in different ways depending on the capabilities (memory size? or the max http request size?)

  • Is there a way to utilize the onWrap() function in your delegate to create submenus when the user reaches the end of the menu? In other words, could you split your list of http endpoints into groups of 5 or 6 items and just initialize new menus so you're not making large data requests all at once? You might have to handle a large stack of views if the user is like 7 menus deep, but I think there might be ways around that. Can you stick all your endpoints in an array and keep track of the current index, and programmatically build your submenus?

    Here's the MenuSampleWrapCustom example from the Menu2Sample project in the SDK files:

    The sub-menu doesn't get called/initialized until the user scrolls through the bottom of the first menu.