' ********** Copyright 2016 Roku Corp. All Rights Reserved. **********
'inits grid screen
'creates all children
'sets all observers
Function Init()
Print"[GridScreen] Init"
m.rowList=m.top.findNode("RowList")
m.description=m.top.findNode("Description")
m.background=m.top.findNode("Background")
m.top.observeField("visible","onVisibleChange")
m.top.observeField("focusedChild","OnFocusedChildChange")
End Function
'handler of focused item in RowList
Sub OnItemFocused()
itemFocused=m.top.itemFocused
If itemFocused.Count()=2
focusedContent=m.top.content.getChild(itemFocused[0]).getChild(itemFocused[1])
If focusedContent<>invalid
m.top.focusedContent=focusedContent
m.description.content=focusedContent
m.background.uri=focusedContent.hdBackgroundImageUrl
else
focusedIndex = m.rowList.rowItemFocused ' get position of focused item
row = m.rowList.content.GetChild(focusedIndex[0]) ' get all items of row
item = row.GetChild(focusedIndex[1]) ' get focused item
numRows = 2
for i = 1 To numRows
row = m.rowList.content.GetChild(focusedIndex[0]+i) ' get all items of row
? row
getMoviesItem(row)
end for
End If
End If
End Sub
'set proper focus to RowList in case if return from Details Screen
Sub onVisibleChange()
If m.top.visible=TRUE
m.rowList.setFocus(TRUE)
End If
End Sub
'set proper focus to RowList in case if return from Details Screen
Sub OnFocusedChildChange()
If m.top.isInFocusChain() And Not m.rowList.hasFocus()
m.rowList.setFocus(TRUE)
End If
End Sub
sub getMoviesItem(parent As Object)
readInternet=createObject("roUrlTransfer")
readInternet.setUrl("http://xoe.ddns.net/RokuDev/api.php?cmd=content&type=movies&category="+parent.id)
source=readInternet.GetToString()
responseJSON = ParseJSON(source)
if responseJSON <> invalid then
For Each itemAA In responseJSON.content
itemNew= parent.CreateChild("ContentNode")
itemNew.Title=itemAA.Title
itemNew.ContentType=itemAA.ContentType
itemNew.ContentId=itemAA.MoviesId
itemNew.Id=itemAA.MoviesId
itemNew.description=itemAA.description
itemNew.url=itemAA.StreamUrls
itemNew.Rating=itemAA.Rating
itemNew.SubtitleUrl=itemAA.SubtitleUrl
itemNew.Length=itemAA.Length
itemNew.streamFormat=itemAA.StreamFormat
itemNew.releasedate=itemAA.ReleaseDate
itemNew.HDPosterURL=itemaa.SDPosterUrl
itemNew.hdbackgroundimageurl=itemaa.HDPosterURL
Next
end if
End sub
Look at the first line in the screen capture you posted. You can’t use roUrlTransfer in the render thread. You have to set up a task.
