2023-05-03 21:21:04 +00:00
|
|
|
import "pkg:/source/api/Items.brs"
|
|
|
|
import "pkg:/source/api/baserequest.brs"
|
|
|
|
import "pkg:/source/utils/config.brs"
|
|
|
|
import "pkg:/source/api/Image.brs"
|
|
|
|
import "pkg:/source/utils/deviceCapabilities.brs"
|
|
|
|
|
2019-05-03 12:48:59 +00:00
|
|
|
sub init()
|
|
|
|
m.top.itemComponentName = "ListPoster"
|
|
|
|
m.top.content = getData()
|
|
|
|
|
|
|
|
updateSize()
|
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.showRowLabel = [true]
|
2019-05-03 12:48:59 +00:00
|
|
|
m.top.rowLabelOffset = [0, 20]
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.showRowCounter = [true]
|
2019-05-03 12:48:59 +00:00
|
|
|
|
|
|
|
' TODO - Define a failed to load image background
|
|
|
|
' m.top.failedBitmapURI
|
|
|
|
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub updateSize()
|
|
|
|
' In search results, rowSize only dictates how many are on screen at once
|
2022-09-05 06:50:13 +00:00
|
|
|
m.top.rowSize = 3
|
2019-05-03 12:48:59 +00:00
|
|
|
|
|
|
|
dimensions = m.top.getScene().currentDesignResolution
|
|
|
|
|
2022-09-05 06:50:13 +00:00
|
|
|
border = 50
|
2019-05-03 12:48:59 +00:00
|
|
|
m.top.translation = [border, border + 115]
|
|
|
|
|
2019-05-10 04:24:19 +00:00
|
|
|
textHeight = 80
|
2022-09-05 06:50:13 +00:00
|
|
|
itemWidth = (dimensions["width"] - border) / 6
|
|
|
|
itemHeight = itemWidth + (textHeight / 2.3)
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2022-09-05 06:50:13 +00:00
|
|
|
m.top.itemSize = [1350, itemHeight] ' this is used for setting the row size
|
|
|
|
m.top.itemSpacing = [0, 105]
|
2019-05-03 12:48:59 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.rowItemSize = [itemWidth, itemHeight]
|
2019-05-03 12:48:59 +00:00
|
|
|
m.top.rowItemSpacing = [0, 0]
|
2022-09-05 06:50:13 +00:00
|
|
|
m.top.numRows = 2
|
|
|
|
m.top.translation = "[12,18]"
|
2019-05-03 12:48:59 +00:00
|
|
|
end sub
|
|
|
|
|
|
|
|
function getData()
|
2021-06-26 13:52:16 +00:00
|
|
|
if m.top.itemData = invalid
|
2019-05-03 12:48:59 +00:00
|
|
|
data = CreateObject("roSGNode", "ContentNode")
|
|
|
|
return data
|
|
|
|
end if
|
|
|
|
|
|
|
|
itemData = m.top.itemData
|
|
|
|
|
|
|
|
' todo - Or get the old data? I can't remember...
|
|
|
|
data = CreateObject("roSGNode", "ContentNode")
|
|
|
|
' Do this to keep the ordering, AssociateArrays have no order
|
2022-09-05 06:50:13 +00:00
|
|
|
type_array = ["Movie", "Series", "TvChannel", "Episode", "MusicArtist", "MusicAlbum", "Audio", "Person", "PlaylistsFolder"]
|
2019-05-03 12:48:59 +00:00
|
|
|
content_types = {
|
2021-07-09 20:08:32 +00:00
|
|
|
"TvChannel": { "label": "Channels", "count": 0 },
|
|
|
|
"Movie": { "label": "Movies", "count": 0 },
|
|
|
|
"Series": { "label": "Shows", "count": 0 },
|
|
|
|
"Episode": { "label": "Episodes", "count": 0 },
|
2022-09-05 06:50:13 +00:00
|
|
|
"MusicArtist": { "label": "Artists", "count": 0 },
|
|
|
|
"MusicAlbum": { "label": "Albums", "count": 0 },
|
2021-07-09 20:08:32 +00:00
|
|
|
"Audio": { "label": "Songs", "count": 0 },
|
2022-09-05 06:50:13 +00:00
|
|
|
"Person": { "label": "People", "count": 0 },
|
|
|
|
"PlaylistsFolder": { "label": "Playlist", "count": 0 }
|
2019-05-03 12:48:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for each item in itemData.searchHints
|
|
|
|
if content_types[item.type] <> invalid
|
|
|
|
content_types[item.type].count += 1
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
|
|
|
|
for each ctype in type_array
|
|
|
|
content_type = content_types[ctype]
|
|
|
|
if content_type.count > 0
|
|
|
|
addRow(data, content_type.label, ctype)
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
|
|
|
|
m.top.content = data
|
|
|
|
return data
|
|
|
|
end function
|
|
|
|
|
2021-06-26 10:18:09 +00:00
|
|
|
sub addRow(data, title, type_filter)
|
2019-05-03 12:48:59 +00:00
|
|
|
itemData = m.top.itemData
|
|
|
|
row = data.CreateChild("ContentNode")
|
|
|
|
row.title = title
|
|
|
|
for each item in itemData.SearchHints
|
|
|
|
if item.type = type_filter
|
|
|
|
row.appendChild(item)
|
|
|
|
end if
|
|
|
|
end for
|
2021-06-26 10:18:09 +00:00
|
|
|
end sub
|
2022-09-05 06:50:13 +00:00
|
|
|
|