On Now displaying, needs click handling

This commit is contained in:
jimiatnymbl 2021-12-16 23:18:19 -07:00
parent a591d4dd6c
commit 8c0fb4a11f
6 changed files with 93 additions and 4 deletions

View File

@ -49,7 +49,7 @@ sub itemContentChanged()
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
else
print "Unhandled Item Type: " + itemData.type
print "Unhandled Grid Item Type: " + itemData.type
end if
'If Poster not loaded, ensure "blue box" is shown until loaded

View File

@ -56,6 +56,19 @@ sub itemContentChanged()
m.itemTextExtra.visible = true
m.itemTextExtra.font.size = 22
if itemData.type = "Program"
m.itemText.Text = itemData.json.name
if (itemData.json.ImageURL <> invalid)
m.itemPoster.uri = itemData.json.ImageURL
end if
' Set Episode title if available
if itemData.json.EpisodeTitle <> invalid
m.itemTextExtra.text = itemData.json.EpisodeTitle
end if
return
end if
if itemData.type = "Episode"
m.itemText.text = itemData.json.SeriesName
@ -156,7 +169,7 @@ sub itemContentChanged()
return
end if
print "Unhandled Item Type: " + itemData.type
print "Unhandled Home Item Type: " + itemData.type
end sub

View File

@ -12,4 +12,7 @@
<field id="itemHasFocus" type="boolean" onChange="focusChanged" />
</interface>
<script type="text/brightscript" uri="HomeItem.brs" />
<script type="text/brightscript" uri="pkg:/source/api/Image.brs" />
<script type="text/brightscript" uri="pkg:/source/api/baserequest.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" />
</component>

View File

@ -24,6 +24,8 @@ sub init()
m.LoadContinueTask.itemsToLoad = "continue"
m.LoadNextUpTask = createObject("roSGNode", "LoadItemsTask")
m.LoadNextUpTask.itemsToLoad = "nextUp"
m.LoadOnNowTask = createObject("roSGNode", "LoadItemsTask")
m.LoadOnNowTask.itemsToLoad = "onNow"
end sub
sub loadLibraries()
@ -79,6 +81,11 @@ sub onLibrariesLoaded()
latestInRow = content.CreateChild("HomeRow")
latestInRow.title = tr("Latest in") + " " + lib.name + " >"
sizeArray.Push([464, 331])
else if lib.collectionType = "livetv"
' If we have Live TV, add "On Now"
onNowRow = content.CreateChild("HomeRow")
onNowRow.title = tr("On Now")
sizeArray.Push([464, 331])
end if
end for
end if
@ -192,7 +199,7 @@ sub updateNextUpItems()
userConfig = m.top.userConfig
filteredLatest = filterNodeArray(m.libraryData, "id", userConfig.LatestItemsExcludes)
for each lib in filteredLatest
if lib.collectionType <> "livetv" and lib.collectionType <> "boxsets"
if lib.collectionType <> "livetv" and lib.collectionType <> "boxsets" and lib.json.CollectionType <> "Program"
loadLatest = createObject("roSGNode", "LoadItemsTask")
loadLatest.itemsToLoad = "latest"
loadLatest.itemId = lib.id
@ -205,6 +212,9 @@ sub updateNextUpItems()
loadLatest.control = "RUN"
end if
end for
m.LoadOnNowTask.observeField("content", "updateOnNowItems")
m.LoadOnNowTask.control = "RUN"
end sub
sub updateLatestItems(msg)
@ -260,6 +270,44 @@ sub updateLatestItems(msg)
end if
end sub
sub updateOnNowItems()
itemData = m.LoadOnNowTask.content
m.LoadOnNowTask.unobserveField("content")
m.LoadOnNowTask.content = []
if itemData = invalid then return
homeRows = m.top.content
onNowRowIndex = getRowIndex("On Now")
if itemData.count() < 1
if onNowRowIndex <> invalid
' remove the row
deleteFromSizeArray(onNowRowIndex)
homeRows.removeChildIndex(onNowRowIndex)
end if
else
' remake row using the new data
row = CreateObject("roSGNode", "HomeRow")
row.title = tr("On Now")
itemSize = [464, 331]
for each item in itemData
item.usePoster = row.usePoster
item.imageWidth = row.imageWidth
row.appendChild(item)
end for
if onNowRowIndex = invalid
' insert new row under "My Media"
updateSizeArray(itemSize, 1)
homeRows.insertChild(row, 1)
else
' replace the old row
homeRows.replaceChild(row, onNowRowIndex)
end if
end if
end sub
function getRowIndex(rowTitle as string)
rowIndex = invalid
for i = 1 to m.top.content.getChildCount() - 1

View File

@ -74,7 +74,28 @@ sub loadItems()
tmp.json = item
results.push(tmp)
end for
else if m.top.itemsToLoad = "onNow"
url = "LiveTv/Programs/Recommended"
params = {}
params["userId"] = get_setting("active_user")
params["isAiring"] = true
params["limit"] = 16
params["imageTypeLimit"] = 1
params["enableImageTypes"] = "Primary,Thumb,Backdrop"
params["enableTotalRecordCount"] = false
params["fields"] = "ChannelInfo,PrimaryImageAspectRatio"
resp = APIRequest(url, params)
data = getJson(resp)
for each item in data.Items
tmp = CreateObject("roSGNode", "HomeData")
item.ImageURL = ImageURL(item.Id)
tmp.json = item
results.push(tmp)
end for
end if
m.top.content = results
end sub

View File

@ -108,6 +108,10 @@
<source>Latest in</source>
<translation>Latest in</translation>
</message>
<message>
<source>On Now</source>
<translation>On Now</translation>
</message>
<message>
<source>Home</source>
<translation>Home</translation>