jf-roku/components/MovieList.xml

85 lines
2.2 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="utf-8" ?>
<component name="MovieRow" extends="RowList">
<interface>
<field id="rowSize" type="int" />
<field id="movieData" type="associativearray" onChange="setData" />
</interface>
<script type="text/brightscript" uri="pkg:/source/config.brs" />
<script type="text/brightscript" uri="pkg:/source/JellyfinAPI.brs" />
<script type="text/brightscript">
<![CDATA[
sub init()
m.top.itemComponentName = "MovieItem"
m.top.content = getData()
m.top.numrows = 1
m.top.rowSize = 4
m.top.visible = true
m.top.itemSize = [200 * 4 + 20 * 3, 70]
m.top.rowHeights = [70]
m.top.rowItemSize = [ [200, 70] ]
m.top.itemSpacing = [ 0, 70 ]
m.top.rowItemSpacing = [ [20, 0] ]
m.top.rowLabelOffset = [ [0, 30] ]
m.top.rowFocusAnimationStyle = "floatingFocus"
m.top.vertFocusAnimationStyle = "floatingFocus"
m.top.showRowLabel = [false]
'm.top.observeField("itemSelected", "onItemSelected")
m.top.setfocus(true)
end sub
function setData()
mvies = m.top.movieData
rowsize = m.top.rowSize
n = mvies.items.count()
' Test for no remainder
if int(n/rowsize) = n/rowsize then
m.top.numRows = n/rowsize
else
m.top.numRows = n/rowsize + 1
end if
m.top.content = getData()
end function
function getData()
if m.top.movieData = invalid then
data = CreateObject("roSGNode", "ContentNode")
return data
end if
mvies = m.top.movieData
rowsize = m.top.rowSize
data = CreateObject("roSGNode", "ContentNode")
for rownum=1 to m.top.numRows
row = data.CreateChild("ContentNode")
for i=1 to rowsize
index = (rownum - 1) * rowsize + i
if index > mvies.items.count() then
exit for
end if
datum = mvies.Items[index-1]
item = row.CreateChild("MovieItemData")
item.labelText = datum.name
item.movieID = datum.id
item.posterUrl = ""
end for
end for
return data
end function
function onItemSelected()
x = m.top.rowItemSelected
target = m.top.content.getChild(x[0]).getChild(x[1])
end function
]]>
</script>
</component>