Skip to content

Commit

Permalink
Merge pull request #230 from neilsb/tv-new-grid
Browse files Browse the repository at this point in the history
Implement new ItemGrid for TV Shows
  • Loading branch information
anthonylavado authored Jun 18, 2020
2 parents 93c64f7 + eea189b commit e0df9f9
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 37 deletions.
4 changes: 4 additions & 0 deletions components/ItemGrid2/GridItem.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions components/ItemGrid2/ItemGrid2.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
m.loadItemsTask.itemType = "Movie"

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

Expand Down
2 changes: 1 addition & 1 deletion components/ItemGrid2/ItemGrid2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
2 changes: 2 additions & 0 deletions components/ItemGrid2/LoadItemsTask2.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions components/data/MovieData.brs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
sub setFields()

' print "Setting Fields in MovieData - " m.top.json.name
json = m.top.json

m.top.id = json.id
Expand Down
54 changes: 42 additions & 12 deletions components/data/SeriesData.brs
Original file line number Diff line number Diff line change
@@ -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

setPoster()
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

'm.top.seasons = TVSeasons(datum.id)
'm.top.nextup = TVNext(datum.id)
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()
end sub

sub setPoster()
if m.top.image <> invalid
m.top.posterURL = m.top.image.url
else
m.top.posterURL = ""
if m.top.image <> invalid
m.top.posterURL = m.top.image.url
else

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
end sub

' 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
9 changes: 4 additions & 5 deletions components/data/SeriesData.xml
Original file line number Diff line number Diff line change
@@ -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>
4 changes: 2 additions & 2 deletions source/Main.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
20 changes: 7 additions & 13 deletions source/ShowScenes.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -252,20 +252,14 @@ function CreateMovieDetailsGroup(movie)
return group
end function

function CreateSeriesListGroup(libraryId)
group = CreateObject("roSGNode", "TVShows")
group.id = libraryId

group.observeField("seriesSelected", m.port)
function CreateSeriesListGroup(libraryItem)

sidepanel = group.findNode("options")
group = CreateObject("roSGNode", "ItemGrid2")
group.parentItem = libraryItem

p = CreatePaginator()
group.appendChild(p)
group.observeField("selectedItem", m.port)

group.pageNumber = 1
p.currentPage = group.pageNumber
SeriesLister(group, m.page_size)
sidepanel = group.findNode("options")

return group
end function
Expand Down

0 comments on commit e0df9f9

Please sign in to comment.