- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Simple extends="TimeGrid" code
Figured out the first step!
TimeGridNode = m.top.findNode("IDTimeGrid")
tempContentNode = CreateObject("roSGNode", "ContentNode")
tempContentNode.Update(rootData)
TimeGridNode.content = tempContentNode
***But cannot figure out how to update the “row” data?***
This is what I am trying:
tempContentNode = CreateObject("roSGNode", "ContentNode")
tempContentNode.Update(RowChildrenData)
row = TimeGridNode.content.GetChild(RowNumberToUpdate)
row.content = tempContentNode
---
I have an existing channel that I wish to add a TimeGrid that does not need to be realtime or lazy loading, etc
As you know, the SGDEX example does show a TimeGrid, but when I tried to merge it with my existing program I had problems! (ComponentController does not want to play with others, etc)
Since I do not want or need the overhead of SGDEX, does anybody have a simple example of how to use the TimeGrid?
Roku confirms that documentation is coming, but it is months away!
Thanks,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Simple extends="TimeGrid" code
So, to add "programs" to the "channel" row:
...
nextShow = {}
nextShow.title = "Program Name Here"
nextShow.description = "Be sure to watch this!"
nextShow.playStart = PlayStartSeconds
nextShow.playDuration = PlayDurationSeconds
newShowItem = row.CreateChild("ContentNode")
newShowItem.Update(nextShow) 'SetFields() also works...
Hope this helps someone!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Simple extends="TimeGrid" code
How I used the TimeGrid: Instead of "channels" this lists by days for 7 days...
Obviously, this is based on the data I had to parse/load, your data will be different...
xml:<interface> I have no idea if these are required, but I just kept from example!
<field id="contentStartTime" type="integer" alias="ID_SchedTimeGrid.contentStartTime" />
<field id="maxDays" type="integer" alias="ID_SchedTimeGrid.maxDays" />
<field id="gridItemSelected" type="array" alwaysNotify="true" />
...
xml:<children>
<TimeGrid id="ID_SchedTimeGrid" translation="[1, 810]" > </TimeGrid>
brs:The "root" is the first column of "channels" - we use for days (only needs to be done once...)
tgSetObserveFieldState(false)
m.SchedTimeGridNode = m.top.findNode("ID_SchedTimeGrid")
'STOP
currentTime = CreateObject("roDateTime")
t = currentTime.AsSeconds()
t = t - (t mod 1800) ' set to a 30m mark...
m.SchedTimeGridNode.contentStartTime = t
currentDate = CreateObject("roDateTime")
currentDate.ToLocalTime()
sDateStr = currentDate.ToISOString()
aDateParts = sDateStr.Tokenize("T")
currentTime.FromISO8601String(aDateParts[0] + " 00:00:00")
'STOP
t = currentTime.AsSeconds()
t += currentTime.GetTimeZoneOffset() * 60
m.SchedTimeGridNode.contentStartTime = t
'STOP
m.SchedTimeGridNode.leftEdgeTargetTime = currentTime.AsSeconds()
m.SchedTimeGridNode.leftEdgeTargetTime = t 'hidden later...
m.SchedTimeGridNode.loadingDataText = "Loading..."
m.SchedTimeGridNode.channelInfoColumnLabel = "[DOWN] to Nav"
m.SchedTimeGridNode.automaticLoadingDataFeedback = true
' m.SchedTimeGridNode.numRows = 4
' m.SchedTimeGridNode.numColumns = 1 'Root columns default
m.SchedTimeGridNode.itemSpacing = [3,3] 'row spaces
m.SchedTimeGridNode.maxDays = 1
m.SchedTimeGridNode.duration = 4900 'program time box width - larger is smaller?
m.SchedTimeGridNode.fillProgramGaps = true
'm.SchedTimeGridNode.timeBarTwoLineLayout = false
'm.SchedTimeGridNode.timeBarMessageText = ""
m.SchedTimeGridNode.timeBarMessagingLayout = true 'Hide date!
m.SchedTimeGridNode.timeBarHeight = 64 'Smaller just for times...
children: []
} ' channels array
TGdaysOfWeek.Push("Sunday")
TGdaysOfWeek.Push("Monday")
TGdaysOfWeek.Push("Tuesday")
TGdaysOfWeek.Push("Wednesday")
TGdaysOfWeek.Push("Thursday")
TGdaysOfWeek.Push("Friday")
TGdaysOfWeek.Push("Saturday")
currDayName = currentTime.GetWeekday()
'STOP
nDayNum = currDayOfWeek
rowLocalBaseDateObj = CreateObject("roDateTime")
rowLocalBaseDateObj.ToLocalTime()
WholeDaySecs = 60 * 60 * 24
while(nDayOffset < 7)
nextWkDay = TGdaysOfWeek[nDayNum]
sDay = rowLocalBaseDateObj.GetDayOfMonth()
sDtDay = sMon.ToStr() + "/" + sDay.ToStr() + " " + nextWkDay
channelNode = makeWeekdayChNode(sDtDay, nDayNum)
nDayNum++
if(nDayNum > 6) then nDayNum = 0
nDayOffset++
tempDtSecs += WholeDaySecs
rowLocalBaseDateObj.FromSeconds(tempDtSecs)
end while
tempContentNode = CreateObject("roSGNode", "ContentNode")
tempContentNode.Update(TGrootChildren)
m.SchedTimeGridNode.content = tempContentNode
brs:After you have loaded the data, use this to load from m.gAllShowsAry
setUTCBaseDateObj = CreateObject("roDateTime")
print "UTC :"; setUTCBaseDateObj.ToISOString(), "TZ:";setUTCBaseDateObj.GetTimeZoneOffset()
setLocalBaseDateObj.ToLocalTime()
'STOP
xUTCDateStr = setUTCBaseDateObj.ToISOString()
dateParts = xUTCDateStr.Tokenize("T") 'assumes 2019-08-29T11:10:00Z
sGridRowsBaseDate = dateParts[0] 'like 2019-08-29
'STOP
nDayOffset = 0
while(nDayOffset < 7) 'Loop for 7 days
xRowDateMatchStr = xRowDateMatchStr.Mid(0, 10)
currRowObj = m.SchedTimeGridNode.content.GetChild(nDayOffset)
nProgCounter = 0
?"m.CurrentShowsType:"m.CurrentShowsType
xProgDate = nextShow.tgProgramLocalStart.ToISOString()
'?"[]xProgDate / xRowDateMatchStr ";xProgDate, xRowDateMatchStr
if(xProgDate.Mid(0, 10) = xRowDateMatchStr) then
'STOP
programInfo = {}
programInfo.title = getCleanStr(nextShow.ProgramName)
programInfo.description = getCleanStr(nextShow.TitleSynopsis)
programInfo.description = "NEW: " + programInfo.description
end if
'?m.SchedTimeGridNode
programInfo.TitleName = getCleanStr(nextShow.TitleName)
programInfo.TitleCode = getCleanStr(nextShow.TitleCode)
programInfo.playDuration = nextShow.tgProgramSecsLen
'STOP
'Adjust base time for each row...
fixBaseDtTime = CreateObject("roDateTime")
fixBaseDtTime.FromSeconds(programInfo.playStart)
fixDayOffset = fixBaseDtTime.AsSeconds()
fixDayOffset -= WholeDaySecs * nDayOffset
fixBaseDtTime.FromSeconds(fixDayOffset)
programInfo.playStart = fixBaseDtTime.AsSeconds()
'STOP
'?"nDayOffset:";nDayOffset, "utc:";nextShow.tgProgramUTCStart.toisostring(), "cst:";nextShow.tgProgramLocalStart.toisostring(),
' ?programInfo.playstart, programInfo.playduration, programInfo.title
newShowItem = currRowObj.CreateChild("ContentNode")
newShowItem.AddFields({ TitleName: "TitleName" })
newShowItem.AddFields({ TitleCode: "TitleCode" })
else
'silly, cuz this should not happen, ever!
chkPS = CreateObject("roDateTime")
chkPS.FromSeconds(programInfo.PlayStart)
?"nProgCounter:"nProgCounter, programInfo, chkPS.ToISOString()
end if
nProgCounter++
tempDtSecs = setLocalBaseDateObj.AsSeconds()
tempDtSecs += WholeDaySecs
setLocalBaseDateObj.FromSeconds(tempDtSecs)
end while
' m.ProgramDesc2.text = "[DOWN] to Nav"
m.SchedTimeGridNode.leftEdgeTargetTime = 0
m.SchedTimeGridNode.jumpToTime = 0
tgSetObserveFieldState(true)
t = currentTime.AsSeconds()
t = t - (t mod 1800) ' set to a 30m mark...
m.SchedTimeGridNode.leftEdgeTargetTime = t
m.SchedTimeGridNode.jumpToTime = t
'STOP
m.SchedTimeGridNode = m.top.findNode("ID_SchedTimeGrid")
m.SchedTimeGridNode.observeField("focusedChild", "tgChildFocused")
m.SchedTimeGridNode.observeField("itemFocused", "tgItemFocused")
m.SchedTimeGridNode.observeField("programFocused", "tgProgramFocused")
m.SchedTimeGridNode.observeField("programSelected", "tgProgramSelected")
m.SchedTimeGridNode.observeField("channelInfoSelected", "tgChannelInfoSelected")
m.SchedTimeGridNode.observeField("channelInfoFocused", "tgChannelInfoFocused")
m.SchedTimeGridNode.observeField("itemUnfocused", "tgChannelUnfocused")
m.SchedTimeGridNode.observeField("programUnfocused", "tgProgramUnfocused")
m.SchedTimeGridNode.observeField("channelInfoUnfocused", "tgChannelInfoUnfocused")
else
m.SchedTimeGridNode.unobserveField("focusedChild")
m.SchedTimeGridNode.unobserveField("itemFocused")
m.SchedTimeGridNode.unobserveField("programFocused")
m.SchedTimeGridNode.unobserveField("programSelected")
m.SchedTimeGridNode.unobserveField("channelInfoSelected")
m.SchedTimeGridNode.unobserveField("channelInfoFocused")
m.SchedTimeGridNode.unobserveField("itemUnfocused")
m.SchedTimeGridNode.unobserveField("programUnfocused")
m.SchedTimeGridNode.unobserveField("channelInfoUnfocused")
end if
Enjoy!