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

Issue with Grid Screen Row/Column Index Not Updating

I'm having a problem with the grid screen that I created. When navigating through the screen (up/down/left/right), the row/column index (in the upper right corner of the screen) is not updating. It just stays at "01 | 01". This is the default index display in the grid screen, not the breadcrumb. My code is below. Please help!

Function showMovieGridScreen(solrIP as string)
port = CreateObject("roMessagePort")
grid = CreateObject("roGridScreen")
grid.SetMessagePort(port)
grid.SetUpBehaviorAtTopRow("exit")

genres = CreateObject("roAssociativeArray")
genres = retrieveGenreList(solrIP, "Movie")

genresCount = 0

for each genre in genres
genresCount = genresCount + 1
end for

rowTitles = CreateObject("roArray", genresCount, true)

for each genre in genres
rowTitles.Push(genre)
end for

grid.SetupLists(rowTitles.Count())
grid.SetListNames(rowTitles)

rowIndex = CreateObject("roInt")
rowIndex.SetInt(0)

for each genre in genres
currentRowList = CreateObject("roArray", genres.Lookup(genre), true)

grid.SetContentList(rowIndex.GetInt(), retrieveMovieDataForGrid(solrIP, genre, currentRowList))

rowIndex.SetInt(rowIndex.GetInt() + 1)
end for

grid.Show()

while true
msg = wait(0, port)
if type(msg) = "roGridScreenEvent" then
if(msg.isScreenClosed()) then
return -1
else if(msg.isListItemFocused()) then
print "Focused msg: ";msg.GetMessage();"row: ";msg.GetIndex();
print " col: ";msg.GetData()
else if(msg.isListItemSelected()) then
print "Selected msg: ";msg.GetMessage();"row: ";msg.GetIndex();
print " col: ";msg.GetData()
end if
endif
end while
End Function

Function retrieveMovieDataForGrid(solrIP as string, genre as string, rowList as object) as object
request = CreateObject("roUrlTransfer")
searchUrl = "http://" + solrIP + ":8080/solr/collection1/select?q=genre:" + genre + "&type:Movie&wt=xml&omitHeader=true"
request.SetUrl(searchUrl)
results = request.GetToString()

xmlRoot = CreateObject("roXMLElement")
xmlContent = CreateObject("xoXMLElement")
xmlFields = CreateObject("roXMLElement")

if xmlRoot.Parse(results) then
xmlContent = xmlRoot.result.getChildElements()

isMovieToAdd = CreateObject("roBoolean")
isMovieToAdd.SetBoolean(false)

for each listing in xmlContent
xmlFields = listing.getChildElements()
for each record in xmlFields

if record@name = "title" then
spaces = CreateObject("roRegex", " ", "i")
movieTitle = spaces.ReplaceAll(record.GetText(), "%20")
movie = CreateObject("roAssociativeArray")
movie.ContentType = "movie"
movie.Title = record.GetText()
movie.SDPosterUrl = "http://" + solrIP + ":8080/Collection/" + movieTitle + "/poster.jpg"
movie.HDPosterUrl = "http://" + solrIP + ":8080/Collection/" + movieTitle + "/poster.jpg"
isMovieToAdd.SetBoolean(true)
end if

if record@name = "rated" then
movie.Rating = record.GetText()
isMovieToAdd.SetBoolean(true)
end if

if record@name = "year" then
movie.ReleaseDate = record.GetText()
isMovieToAdd.SetBoolean(true)
end if

if record@name = "starRating" then
movie.StarRating = record.GetText()
isMovieToAdd.SetBoolean(true)
end if

if record@name = "runtime" then
runtimeRegex = CreateObject("roRegex", " min", "i")
movieRuntime = runtimeRegex.ReplaceAll(record.GetText(), "").toInt()
movieRuntime = movieRuntime * 60
movie.Length = movieRuntime.toStr()
isMovieToAdd.SetBoolean(true)
end if

if record@name = "plot" then
movie.Description = record.GetText()
isMovieToAdd.SetBoolean(true)
end if
next

if isMovieToAdd.GetBoolean() then
rowList.Push(movie)
end if
next
end if

return rowList
End Function
0 Kudos
3 REPLIES 3
RokuRobB
Streaming Star

Re: Issue with Grid Screen Row/Column Index Not Updating

The row | column counter in a grid screen should update without any channel specific BrightScript code. If the grid is populated with content this should update automatically when navigating through the grid. You could try trimming your channel down to just the grid, populated with test / dummy content to see if the grid performs as expected in that case. Then start adding back the code for populating the grid with your real content and see where the counter stops working. That might help unconver an issue in the channel.
0 Kudos
krh5150
Visitor

Re: Issue with Grid Screen Row/Column Index Not Updating

Thanks Joel! It was my mistake. I mistook the two numbers at the top right as row and column. After further testing with more than 1 entry per row, I noticed that it was the number of the current viewed entry for that row in the list followed by the total number of entries in that row. I ended up confirming it on the Netflix channel.

Thanks,
Kevin
0 Kudos
destruk
Binge Watcher

Re: Issue with Grid Screen Row/Column Index Not Updating

If you have an empty/invalid row for a category, the grid numbers are either not populated (if the initial focused category), or do not change (if you move from a populated category to an empty one) - I think this is by design.
0 Kudos