Forum Discussion
In the past I've used a global assocarray as a lookup table to control elements on grid/row items (for progress, favourites, etc) and that worked - but it doesn't help to update an existing grid when something changes. You probably don't want to be observing something on global from every item.
It's weird that jumptoitem is hiding your 'watched' poster, probably worth focusing your efforts on figuring out why that's happening. Without seeing MarkupGridItem.brs I don't have a good answer but that's where I'd look.
- cesarcarlos3 years agoBinge Watcher
Thanks sanity-check for the suggestion.
Here is the code for the MarkUpItem.brs
sub init() m.top.id = "markupgriditem" m.itemposter = m.top.findNode("poster") m.lessonNumber = m.top.findNode("lessonNumber") m.watched = m.top.findNode("watched") 'the checkmark end sub sub showcontent() ? "ShowContent" itemcontent = m.top.itemContent m.itemposter.uri = itemcontent.url m.lessonNumber.text = "Day " + itemcontent.shortdescriptionline1 watchedArray = m.top.getParent().getParent().watched 'watched field (array) in the screen node if contains(watchedArray, (itemcontent.shortdescriptionline1).toInt()) m.watched.visible = true m.watched.uri = "https://path/check_sequence.png" else m.watched.visible = false end if end sub function contains(arr as Object, value as Integer) as Boolean for each entry in arr if entry = value return true end if end for return false end functionThis is the code that is running whenever returning from the video to the screen with the markupgrid
sub AddCheckmark(event as Object) w = m.top.watched w.push(m.top.track) m.top.watched = w m.lessonsList.content = m.lessonsContent 'this has the data for all items in grid m.lessonsList.jumptoitem = m.lessonsList.itemFocused end subThe problem I have noticed is that if I don't add the last line, all items are rendered (The "Show COntent" message is printed for each item). But if I add the jumptoitem line, only a couple "Show Content" messages appear and then rendering stops and the rest of the list remains without updating. Thus, the checkmark doesn't appear.
- sanity-check3 years agoRoku Guru
Interesting! The getparent().getparent() thing works in grid item node. I've learned something at least.
I always feel like there's some tricky extra-threads stuff going on in the background with those, so it's possible things are happening in a different order to what we might expect.
What happens if you add some logging just before .jumptoitem ? Do "ShowContent" logs happen before, after, or a mix?
An alternative thing you can try, as your 'watched' list is in the same place as your content, is adding a .watched boolean field to your content nodes, and setting it to true for the relevant ones before reassigning .content=lessonsContent. Then your nodes are your single source of data for the grid, which I think is closer to how Roku intends these to work.
(Extend ContentNode, or use addField+setField)
- cesarcarlos3 years agoBinge Watcher
In the end I managed to fin a way to do it. I used the itemHasFocus field:
<component name = "MarkupGridItem" extends = "Group" > <interface> <field id = "itemContent" type = "node" onChange = "showcontent"/> <field id = "itemHasFocus" type = "float" onChange = "showfocus"/> </interface>sub showfocus(event as Object) if event.getData() = 1 watchedArray = m.top.getParent().getParent().watched if contains(watchedArray, m.number) m.watched.visible = true m.watched.uri = "https://path/check_sequence.png" end if end if end subWorks in my case because these are very short videos that don't move automatically from one video to the next, so the selected video is the one that has the focus upon returning from the video screen. The updating of the watched list happens before this runs.