I’m developing an application using SGDEX components and have successfully loaded content into a GridView. When a user selects an item, I switch to a DetailsView to show more information. I use a custom ContentHandler to fetch the details from my API.
My problem is that the GetContent() function in my ContentHandler is being called infinitely, leading to my Roku device crashing. The content loads correctly the first time, but the repeated calls eventually overload the device, and it crashes.
Any help or suggestions on how to resolve this would be greatly appreciated.
DetailsViewLogic.brs
function ShowDetailsView(rowContent as object, index as integer, isContentList = true as boolean) as object
details = CreateObject("roSGNode", "DetailsView")
content = CreateObject("roSGNode", "ContentNode")
content.AddFields({
HandlerConfigDetails: {
name: "ContentHandlerDetail"
},
item: rowContent.GetChild(index)
isContentLoaded: false
})
details.ObserveField("currentItem", "OnDetailsContentSet")
details.ObserveField("buttonSelected", "OnButtonSelected")
details.SetFields({
content: content
isContentList: true
contentManagerType: "details"
})
m.top.ComponentController.CallFunc("show", {
view: details
})
return details
end function
ContentHandlerDetail.brs
sub GetContent()
print "ContentHandlerDetail.brs GetContent() was called"
' Redacted
' ...
end sub
Output from console
SGDEX: create new view: DetailsView
SGDEX: View Manager runProcedure addView
SGDEX: newView.setFocus(true)
ContentHandlerDetail.brs GetContent() was called
ContentHandlerDetail.brs GetContent() was called
ContentHandlerDetail.brs GetContent() was called
ContentHandlerDetail.brs GetContent() was called
ContentHandlerDetail.brs GetContent() was called
ContentHandlerDetail.brs GetContent() was called
ContentHandlerDetail.brs GetContent() was called
ContentHandlerDetail.brs GetContent() was called
ContentHandlerDetail.brs GetContent() was called
ContentHandlerDetail.brs GetContent() was called