Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
drinkrain
Visitor

Rowlist re-renders/changes focus after loading more content

So I have a rowlist that has an onitemfocus event which sends the focuseditem's data - "focusedContent contentnode" (defined by a getCategories Task) to display an Image, Title, Description, Duration component.

Also when I 'onitemfocus', a Get Rating task runs, which does an api call and grabs the rating and displays the rating by star Posters. This works fine.

What I want to do is prevent the get rating task to run on previous items by updating the FocusedContent  content node with a userrating value. I can do this. BUT once that value gets updated the Rowlist either re-renders / loses focus. It gets reset to the 0 item in the row.

I have unobserved the focused content while the data is being updated. but as soon as I re-observe the rowlist re-renders/re-focuses.

Does anybody have a clue to what is going on?
THANKS  
0 Kudos
4 REPLIES 4
Tyler_Smith
Binge Watcher

Re: Rowlist re-renders/changes focus after loading more content

Rather than using the focused index, I recommend looking at the rendertarcking property (https://sdkdocs.roku.com/display/sdkdoc/Group)

This would allow your items to sit dormant until they are in view and the can execute your task (and then unobserve).

Example

sub init()
 m.top.enableRenderTracking = true
 m.top.observeFieldScoped("renderTracking", "onProcessRenderTracking")
end sub

sub onProcessRenderTracking(message)
 if "full" = m.top.renderTracking OR "full" = m.top.renderTracking then
   m.top.unobserveFieldScoped("renderTracking")
   ' FIRE OFF YOUR TASK HERE
 end if
end sub
Tyler Smith
0 Kudos
drinkrain
Visitor

Re: Rowlist re-renders/changes focus after loading more content

While this sounds intriguing, I am still not fully comprehending how to apply this.

Right now I am just following the rowlist examples in the dev repos and Yes they are using the focused index. 

Aren't the items staying dormant until they get focused? If I use render tracking, what part of the rowlist would I be tracking. Would I be looking at the rowlist items and running tasks on every child that is visible?

This doesn't solve my original issue but it does sound like a way of optimizing things- I just don't see the whole picture.
0 Kudos
drinkrain
Visitor

Re: Rowlist re-renders/changes focus after loading more content

... right now I understand that I am observing "itemFocused" which means that then entire rowlist is being observed. So if I can observe  what is just viewable that makes the most sense. But I don't know how I would replace the index tracking.... hmmm. I'll keep trying.
0 Kudos
drinkrain
Visitor

Re: Rowlist re-renders/changes focus after loading more content

Still wondering if anybody has ran into this issue before!
0 Kudos