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: 
nmaves
Visitor

Dynamically update TargetList / TargetGroup

I have a TargetList that works great.  The only issue I am seeing is when I need to refresh the content of that TargetList.

Bellow is how I am updating the content.  Here is the use case that I am seeing.   Our list is ordered from most recently played to least recently played.  Let's say I have 4 titles in the list.  I have a timer that runs every 30 seconds to pull the list of titles from our web service and update the TargetList.  The user now plays the 4th title in the list.  When they come back to the screen with the TargetList on it it has refreshed but the UI is showing that title twice in the target list.   It does not appear to refresh properly.  It might have to do with some of the tiles being outside of the focus set but I can't be sure.  

Is there a proper way to update the content of a TargetList / TargetGroup ?

m.titlesList.content = m.borrowedTitlesTask.content
0 Kudos
7 REPLIES 7
joetesta
Roku Guru

Re: Dynamically update TargetList / TargetGroup

based on my experience with other components, I think the best approach will be to loop over each element and update their component contents individually.  In other words, overwrite values for "text" and "uri" fields rather than trying to overwrite the whole content in one shot.
Alternatively, create a new targetlist from your new content and replace your initial targetlist (get / set your focus along the way)
hope it may help,
Joe
aspiring
0 Kudos
nmaves
Visitor

Re: Dynamically update TargetList / TargetGroup

Well, that is something I can try.  I also noticed that the items do update if they move outside the targetset and come back in.  Strange right?

Though this suggestion is kind of a pain.  You have to update existing items or remove them if the new list is smaller than the currently displayed list.  Or append them if there are more.  It should just work by updating the targetlist.content.

Nathan
0 Kudos
joetesta
Roku Guru

Re: Dynamically update TargetList / TargetGroup

yes - you need to remove extra elements or createObject for additional ones.
Yes it is a pain, so was figuring it out by trial and error!  Hey man, I didn't write this firmware, just trying to help 🙂
Maybe try my 2nd suggestion, instantiate a new object with your new content and replace the existing?
aspiring
0 Kudos
nmaves
Visitor

Re: Dynamically update TargetList / TargetGroup

Re-creating the TargetList actually works but you see a pretty bad flicker.

I really wish that the Roku dev team would at least comment on issues like this.  I think I have created 10+ posts in the forums and they never seem to contribute.

Nathan
0 Kudos
nmaves
Visitor

Re: Dynamically update TargetList / TargetGroup

So there seems to be so much wrong with the TargetGroup.

I have tried both ways that you suggested and while the list is updated in both cases the TargetGroup fails to update it's internal focusIndex.

So after I have deleted all of the content nodes and replaced them the focus could still be on item 3 (or any greater than 0).

If I call the below code the UI updates to show the first item of the list is now focused but if you try to use the arrows left and right the UI updates as if the old focusIndex was still set.
m.titlesList.animateToItem = 0

 
0 Kudos
joetesta
Roku Guru

Re: Dynamically update TargetList / TargetGroup

Not sure whether there's a way to override that, I haven't worked much with the "Target" components.
As far as the screen flashing I believe there was a workaround to fade out the container and fade it back in after the child component replacement.  Don't hold me to it 🙂
aspiring
0 Kudos
owen777
Binge Watcher

Re: Dynamically update TargetList / TargetGroup

Will someone from Roku do something about these bugs? Will we see at least an official comment?
0 Kudos