Implement new ItemGrid for TV Shows

This commit is contained in:
Neil Burrows 2020-06-15 17:05:48 +01:00
parent 93c64f7422
commit eea189bd97
9 changed files with 71 additions and 37 deletions

View File

@ -15,6 +15,10 @@ sub itemContentChanged()
itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
return
else if itemData.type = "Series" then
itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
return
end if
print "Unhandled Item Type: " + itemData.type

View File

@ -29,9 +29,16 @@ end sub
'
'Load initial set of Data
sub loadInitialItems()
m.loadItemsTask.itemId = m.top.itemId
m.loadItemsTask.itemId = m.top.parentItem.Id
m.loadItemsTask.observeField("content", "ItemDataLoaded")
if m.top.parentItem.collectionType = "movies" then
m.loadItemsTask.itemType = "Movie"
else if m.top.parentItem.collectionType = "tvshows" then
m.loadItemsTask.itemType = "Series"
end if
m.loadItemsTask.control = "RUN"
end sub

View File

@ -30,7 +30,7 @@
</Animation>
</children>
<interface>
<field id="itemId" type="string" onChange="loadInitialItems" />
<field id="parentItem" type="node" onChange="loadInitialItems" />
<field id="selectedItem" type="node" alwaysNotify="true" />
</interface>
<script type="text/brightscript" uri="ItemGrid2.brs" />

View File

@ -36,6 +36,8 @@ sub loadItems()
tmp = invalid
if item.Type = "Movie" then
tmp = CreateObject("roSGNode", "MovieData")
else if item.Type = "Series" then
tmp = CreateObject("roSGNode", "SeriesData")
else
print "Unknown Type: " item.Type

View File

@ -1,6 +1,4 @@
sub setFields()
' print "Setting Fields in MovieData - " m.top.json.name
json = m.top.json
m.top.id = json.id

View File

@ -1,19 +1,49 @@
sub setFields()
datum = m.top.json
m.top.id = datum.id
m.top.title = datum.name
m.top.overview = datum.overview
json = m.top.json
m.top.id = json.id
m.top.Title = json.name
m.top.Description = json.overview
m.top.favorite = json.UserData.isFavorite
m.top.watched = json.UserData.played
m.top.Type = "Series"
m.top.overview = json.overview
if json.ProductionYear <> invalid then
m.top.SubTitle = json.ProductionYear
end if
if json.OfficialRating <> invalid and json.OfficialRating <> "" then
m.top.Rating = json.OfficialRating
if m.top.SubTitle <> "" then
m.top.SubTitle = m.top.SubTitle + " - " + m.top.Rating
else
m.top.SubTitle = m.top.Rating
end if
end if
setPoster()
'm.top.seasons = TVSeasons(datum.id)
'm.top.nextup = TVNext(datum.id)
end sub
sub setPoster()
if m.top.image <> invalid
m.top.posterURL = m.top.image.url
else
m.top.posterURL = ""
if m.top.json.ImageTags.Primary <> invalid then
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag" : m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
else if m.top.json.BackdropImageTags <> invalid then
imgParams = { "maxHeight": 440, "Tag" : m.top.json.BackdropImageTags[0] }
m.top.posterURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
end if
' Add Backdrop Image
if m.top.json.BackdropImageTags <> invalid then
imgParams = { "maxHeight": 720, "maxWidth": 1280, "Tag" : m.top.json.BackdropImageTags[0] }
m.top.backdropURL = ImageURL(m.top.json.id, "Backdrop", imgParams)
end if
end if
end sub

View File

@ -1,15 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="SeriesData" extends="ContentNode">
<component name="SeriesData" extends="JFContentItem">
<interface>
<field id="id" type="string" />
<field id="title" type="string" />
<field id="overview" type="string" />
<field id="seasons" type="associativearray" />
<field id="nextup" type="associativearray" />
<field id="image" type="node" onChange="setPoster" />
<field id="posterURL" type="string" />
<field id="json" type="associativearray" onChange="setFields" />
<function name="loadSeasons" />
</interface>
<script type="text/brightscript" uri="SeriesData.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

@ -82,7 +82,7 @@ sub Main()
group.setFocus(false)
group.visible = false
m.overhang.title = selectedItem.name
group = CreateMovieListGroup(selectedItem.Id)
group = CreateMovieListGroup(selectedItem)
group.overhangTitle = selectedItem.name
m.scene.appendChild(group)
else if (selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView") AND selectedItem.collectionType = "tvshows"
@ -91,7 +91,7 @@ sub Main()
group.visible = false
m.overhang.title = selectedItem.name
group = CreateSeriesListGroup(selectedItem.Id)
group = CreateSeriesListGroup(selectedItem)
group.overhangTitle = selectedItem.name
m.scene.appendChild(group)
else if (selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView") AND selectedItem.collectionType = "boxsets"

View File

@ -195,9 +195,9 @@ function CreateHomeGroup()
return group
end function
function CreateMovieListGroup(libraryId)
function CreateMovieListGroup(libraryItem)
group = CreateObject("roSGNode", "ItemGrid2")
group.itemId = libraryId
group.parentItem = libraryItem
group.observeField("selectedItem", m.port)
@ -252,21 +252,15 @@ function CreateMovieDetailsGroup(movie)
return group
end function
function CreateSeriesListGroup(libraryId)
group = CreateObject("roSGNode", "TVShows")
group.id = libraryId
function CreateSeriesListGroup(libraryItem)
group.observeField("seriesSelected", m.port)
group = CreateObject("roSGNode", "ItemGrid2")
group.parentItem = libraryItem
group.observeField("selectedItem", m.port)
sidepanel = group.findNode("options")
p = CreatePaginator()
group.appendChild(p)
group.pageNumber = 1
p.currentPage = group.pageNumber
SeriesLister(group, m.page_size)
return group
end function