Merge pull request #234 from neilsb/collections-new-itemgrid

Support BoxSets & Collections in new Item Grid
This commit is contained in:
Anthony Lavado 2020-07-01 23:39:22 -07:00 committed by GitHub
commit 325a03a8de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 75 deletions

View File

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

View File

@ -16,7 +16,7 @@ sub loadItems()
parentid: m.top.itemId, parentid: m.top.itemId,
SortBy: sort_field, SortBy: sort_field,
SortOrder: sort_order, SortOrder: sort_order,
recursive: false recursive: true
} }
if m.top.ItemType <> "" then if m.top.ItemType <> "" then
@ -38,6 +38,8 @@ sub loadItems()
tmp = CreateObject("roSGNode", "MovieData") tmp = CreateObject("roSGNode", "MovieData")
else if item.Type = "Series" then else if item.Type = "Series" then
tmp = CreateObject("roSGNode", "SeriesData") tmp = CreateObject("roSGNode", "SeriesData")
else if item.Type = "BoxSet" then
tmp = CreateObject("roSGNode", "CollectionData")
else else
print "Unknown Type: " item.Type print "Unknown Type: " item.Type

View File

@ -1,18 +1,37 @@
sub setFields() sub setFields()
datum = m.top.json json = m.top.json
m.top.id = datum.id m.top.id = json.id
m.top.title = datum.name m.top.Title = json.name
m.top.overview = datum.overview m.top.overview = json.overview
m.top.Description = json.overview
m.top.favorite = datum.UserData.isFavorite m.top.favorite = json.UserData.isFavorite
m.top.watched = datum.UserData.played m.top.watched = json.UserData.played
m.top.Type = "Boxset"
setPoster()
end sub end sub
sub setPoster() sub setPoster()
if m.top.image <> invalid if m.top.image <> invalid
m.top.posterURL = m.top.image.url m.top.posterURL = m.top.image.url
else 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 if
end sub end sub

View File

@ -1,16 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<component name="CollectionData" extends="ContentNode"> <component name="CollectionData" extends="JFContentItem">
<interface> <interface>
<field id="title" type="string" />
<field id="image" type="node" onChange="setPoster" />
<field id="posterUrl" type="string" />
<field id="collectionID" type="string" /> <field id="collectionID" type="string" />
<field id="description" type="string" /> <field id="description" type="string" />
<field id="favorite" type="boolean" />
<field id="watched" type="boolean" />
<field id="type" type="string" value="boxsets" />
<field id="overview" type="string" value="boxsets" /> <field id="overview" type="string" value="boxsets" />
<field id="json" type="associativearray" onChange="setFields" />
</interface> </interface>
<script type="text/brightscript" uri="CollectionData.brs" /> <script type="text/brightscript" uri="CollectionData.brs" />
</component> <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

@ -100,7 +100,7 @@ sub Main()
group.visible = false group.visible = false
m.overhang.title = selectedItem.name m.overhang.title = selectedItem.name
group = CreateCollectionsList(selectedItem.Id) group = CreateCollectionsList(selectedItem)
group.overhangTitle = selectedItem.name group.overhangTitle = selectedItem.name
m.scene.appendChild(group) m.scene.appendChild(group)
else if (selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView") AND selectedItem.collectionType = "livetv" else if (selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView") AND selectedItem.collectionType = "livetv"
@ -112,6 +112,16 @@ sub Main()
group = CreateChannelList(selectedItem.Id) group = CreateChannelList(selectedItem.Id)
group.overhangTitle = selectedItem.name group.overhangTitle = selectedItem.name
m.scene.appendChild(group) m.scene.appendChild(group)
else if selectedItem.type = "Boxset" then
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
m.overhang.title = selectedItem.title
group = CreateCollectionDetailList(selectedItem.Id)
group.overhangTitle = selectedItem.title
m.scene.appendChild(group)
else if selectedItem.type = "Episode" then else if selectedItem.type = "Episode" then
' play episode ' play episode
' todo: create an episode page to link here ' todo: create an episode page to link here
@ -175,17 +185,6 @@ sub Main()
end if end if
selectedItem = invalid selectedItem = invalid
end if end if
else if isNodeEvent(msg, "collectionSelected")
node = getMsgPicker(msg, "picker")
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
m.overhang.title = node.title
group = CreateCollectionDetailList(node.Id)
group.overhangTitle = node.title
m.scene.appendChild(group)
else if isNodeEvent(msg, "movieSelected") else if isNodeEvent(msg, "movieSelected")
' If you select a movie from ANYWHERE, follow this flow ' If you select a movie from ANYWHERE, follow this flow
node = getMsgPicker(msg, "picker") node = getMsgPicker(msg, "picker")

View File

@ -286,54 +286,14 @@ function CreateSeasonDetailsGroup(series, season)
return group return group
end function end function
function CreateCollectionsList(libraryId) function CreateCollectionsList(libraryItem)
' Load Collection Items
group = CreateObject("roSGNode", "Collections")
group.id = libraryId
group.observeField("collectionSelected", m.port) group = CreateObject("roSGNode", "ItemGrid2")
group.parentItem = libraryItem
group.observeField("selectedItem", m.port)
sidepanel = group.findNode("options") sidepanel = group.findNode("options")
panel_options = [
{"title": tr("Sort Field"),
"base_title": tr("Sort Field"),
"key": "movie_sort_field",
"default": "SortName",
"values": [
{display: tr("Date Added"), value: "DateCreated"},
{display: tr("Release Date"), value: "PremiereDate"},
{display: tr("Name"), value: "SortName"}
]},
{"title": tr("Sort Order"),
"base_title": tr("Sort Order"),
"key": "movie_sort_order",
"default": "Ascending",
"values": [
{display: tr("Descending"), value: "Descending"},
{display: tr("Ascending"), value: "Ascending"}
]}
]
new_options = []
for each opt in panel_options
o = CreateObject("roSGNode", "OptionsData")
o.title = opt.title
o.choices = opt.values
o.base_title = opt.base_title
o.config_key = opt.key
o.value = get_user_setting(opt.key, opt.default)
new_options.append([o])
end for
sidepanel.options = new_options
sidepanel.observeField("closeSidePanel", m.port)
p = CreatePaginator()
group.appendChild(p)
group.pageNumber = 1
p.currentPage = group.pageNumber
CollectionLister(group, m.page_size)
return group return group
end function end function