Your Digital Media Has Never Looked So Good

 
nmaves
Topic Author
Posts: 35
Joined: Mon Jul 10, 2017 6:52 pm

Dynamically update TargetList / TargetGroup

Wed Oct 11, 2017 9:23 am

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
 
joetesta
Posts: 541
Joined: Wed Apr 20, 2011 11:48 am

Re: Dynamically update TargetList / TargetGroup

Wed Oct 11, 2017 10:21 am

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
 
nmaves
Topic Author
Posts: 35
Joined: Mon Jul 10, 2017 6:52 pm

Re: Dynamically update TargetList / TargetGroup

Wed Oct 11, 2017 11:16 am

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
 
joetesta
Posts: 541
Joined: Wed Apr 20, 2011 11:48 am

Re: Dynamically update TargetList / TargetGroup

Wed Oct 11, 2017 12:09 pm

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
 
nmaves
Topic Author
Posts: 35
Joined: Mon Jul 10, 2017 6:52 pm

Re: Dynamically update TargetList / TargetGroup

Thu Oct 12, 2017 7:18 pm

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
 
nmaves
Topic Author
Posts: 35
Joined: Mon Jul 10, 2017 6:52 pm

Re: Dynamically update TargetList / TargetGroup

Thu Oct 12, 2017 10:45 pm

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

 
 
joetesta
Posts: 541
Joined: Wed Apr 20, 2011 11:48 am

Re: Dynamically update TargetList / TargetGroup

Fri Oct 13, 2017 7:53 am

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

Who is online

Users browsing this forum: No registered users and 6 guests