Merge pull request #277 from bisby/options-sort

Add a favorites filter to movies
This commit is contained in:
Anthony Lavado 2020-10-29 00:03:38 -04:00 committed by GitHub
commit f6af78ae4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 10 deletions

View File

@ -29,6 +29,8 @@ sub init()
m.sortField = "SortName" m.sortField = "SortName"
m.sortAscending = true m.sortAscending = true
m.filter = "All"
m.loadItemsTask = createObject("roSGNode", "LoadItemsTask2") m.loadItemsTask = createObject("roSGNode", "LoadItemsTask2")
m.loadItemsTask.observeField("content", "ItemDataLoaded") m.loadItemsTask.observeField("content", "ItemDataLoaded")
@ -45,6 +47,7 @@ sub loadInitialItems()
m.loadItemsTask.itemId = m.top.parentItem.Id m.loadItemsTask.itemId = m.top.parentItem.Id
m.loadItemsTask.sortField = m.sortField m.loadItemsTask.sortField = m.sortField
m.loadItemsTask.sortAscending = m.sortAscending m.loadItemsTask.sortAscending = m.sortAscending
m.loadItemsTask.filter = m.filter
m.loadItemsTask.startIndex = 0 m.loadItemsTask.startIndex = 0
if m.top.parentItem.collectionType = "movies" then if m.top.parentItem.collectionType = "movies" then
@ -70,7 +73,9 @@ sub SetUpOptions()
'Movies 'Movies
if m.top.parentItem.collectionType = "movies" then if m.top.parentItem.collectionType = "movies" then
options.views = [{ "Title": tr("Movies"), "Name": "movies" }] options.views = [
{ "Title": tr("Movies"), "Name": "movies" },
]
options.sort = [ options.sort = [
{ "Title": tr("TITLE"), "Name": "SortName" }, { "Title": tr("TITLE"), "Name": "SortName" },
{ "Title": tr("IMDB_RATING"), "Name": "CommunityRating" }, { "Title": tr("IMDB_RATING"), "Name": "CommunityRating" },
@ -82,6 +87,10 @@ sub SetUpOptions()
{ "Title": tr("RELEASE_DATE"), "Name": "PremiereDate" }, { "Title": tr("RELEASE_DATE"), "Name": "PremiereDate" },
{ "Title": tr("RUNTIME"), "Name": "Runtime" } { "Title": tr("RUNTIME"), "Name": "Runtime" }
] ]
options.filter = [
{ "Title": tr("All"), "Name": "All" },
{ "Title": tr("Favorites"), "Name": "Favorites" }
]
'TV Shows 'TV Shows
else if m.top.parentItem.collectionType = "tvshows" then else if m.top.parentItem.collectionType = "tvshows" then
options.views = [{ "Title": tr("Shows"), "Name": "shows" }] options.views = [{ "Title": tr("Shows"), "Name": "shows" }]
@ -109,6 +118,12 @@ sub SetUpOptions()
end if end if
end for end for
for each o in options.filter
if o.Name = m.filter then
o.Selected = true
end if
end for
m.options.options = options m.options.options = options
end sub end sub
@ -229,9 +244,17 @@ end sub
' '
'Check if options updated and any reloading required 'Check if options updated and any reloading required
sub optionsClosed() sub optionsClosed()
reload = false
if m.options.sortField <> m.sortField or m.options.sortAscending <> m.sortAscending then if m.options.sortField <> m.sortField or m.options.sortAscending <> m.sortAscending then
m.sortField = m.options.sortField m.sortField = m.options.sortField
m.sortAscending = m.options.sortAscending m.sortAscending = m.options.sortAscending
reload = true
end if
if m.options.filter <> m.filter then
m.filter = m.options.filter
reload = true
end if
if reload
m.loadedRows = 0 m.loadedRows = 0
m.loadedItems = 0 m.loadedItems = 0
m.data = CreateObject("roSGNode", "ContentNode") m.data = CreateObject("roSGNode", "ContentNode")

View File

@ -14,6 +14,7 @@ sub init()
m.viewNames = [] m.viewNames = []
m.sortNames = [] m.sortNames = []
m.filterNames = []
' Animation ' Animation
m.fadeAnim = m.top.findNode("fadeAnim") m.fadeAnim = m.top.findNode("fadeAnim")
@ -78,6 +79,33 @@ sub optionsSet()
end if end if
end if end if
' Filter Tab
if m.top.options.filter <> invalid then
filterContent = CreateObject("roSGNode", "ContentNode")
index = 0
m.selectedFilterIndex = 0
for each filterItem in m.top.options.filter
entry = filterContent.CreateChild("ContentNode")
entry.title = filterItem.Title
m.filterNames.push(filterItem.Name)
if filterItem.selected <> invalid and filterItem.selected = true then
m.selectedFilterIndex = index
end if
index = index + 1
end for
m.menus[2].content = filterContent
m.menus[2].checkedItem = m.selectedFilterIndex
else
filterContent = CreateObject("roSGNode", "ContentNode")
entry = filterContent.CreateChild("ContentNode")
entry.title = "All"
m.filterNames.push("All")
m.menus[2].content = filterContent
m.menus[2].checkedItem = 0
end if
end sub end sub
' Switch menu shown when button focus changes ' Switch menu shown when button focus changes
@ -106,8 +134,8 @@ function onKeyEvent(key as string, press as boolean) as boolean
return true return true
else if key = "OK" else if key = "OK"
' Handle Sort screen
if(m.menus[m.selectedItem].isInFocusChain()) then if(m.menus[m.selectedItem].isInFocusChain()) then
' Handle Sort screen
if(m.selectedItem = 1) then if(m.selectedItem = 1) then
if m.menus[1].itemSelected <> m.selectedSortIndex then if m.menus[1].itemSelected <> m.selectedSortIndex then
m.menus[1].focusedCheckedIconUri = m.global.constants.icons.ascending_black m.menus[1].focusedCheckedIconUri = m.global.constants.icons.ascending_black
@ -129,6 +157,11 @@ function onKeyEvent(key as string, press as boolean) as boolean
end if end if
end if end if
end if end if
' Handle Filter screen
if(m.selectedItem = 2) then
m.selectedFilterIndex = m.menus[2].itemSelected
m.top.filter = m.filterNames[m.selectedFilterIndex]
end if
end if end if
return true return true
else if key = "back" or key = "up" else if key = "back" or key = "up"

View File

@ -11,11 +11,8 @@
</RadiobuttonList> </RadiobuttonList>
<RadiobuttonList id="sortMenu" itemspacing="[0,10]" vertFocusAnimationStyle="floatingFocus" opacity="1" numRows="8" drawFocusFeedback="false"> <RadiobuttonList id="sortMenu" itemspacing="[0,10]" vertFocusAnimationStyle="floatingFocus" opacity="1" numRows="8" drawFocusFeedback="false">
</RadiobuttonList> </RadiobuttonList>
<LabelList id = "filterMenu" itemspacing="[0,10]" vertFocusAnimationStyle="floatingFocus" opacity="0" drawFocusFeedback="false"> <RadiobuttonList id="filterMenu" itemspacing="[0,10]" vertFocusAnimationStyle="floatingFocus" opacity="0" drawFocusFeedback="false">
<ContentNode id = "filterMenuContent" role = "content"> </RadiobuttonList>
<ContentNode title = "Coming Soon..." />
</ContentNode>
</LabelList>
</Group> </Group>
</LayoutGroup> </LayoutGroup>
</Group> </Group>
@ -33,6 +30,7 @@
<field id="view" type="string" /> <field id="view" type="string" />
<field id="sortField" type="string" value="SortName" /> <field id="sortField" type="string" value="SortName" />
<field id="sortAscending" type="boolean" value="false" /> <field id="sortAscending" type="boolean" value="false" />
<field id="filter" type="string" value="All" />
</interface> </interface>
<script type="text/brightscript" uri="ItemGridOptions.brs" /> <script type="text/brightscript" uri="ItemGridOptions.brs" />

View File

@ -14,6 +14,7 @@ sub loadItems()
sort_order = "Descending" sort_order = "Descending"
end if end if
params = { params = {
limit: m.top.limit, limit: m.top.limit,
StartIndex: m.top.startIndex, StartIndex: m.top.startIndex,
@ -24,6 +25,13 @@ sub loadItems()
Fields: "Overview" Fields: "Overview"
} }
filter = m.top.filter
if filter = "All" or filter = "all" then
' do nothing
else if filter = "Favorites" then
params.append({ Filters: "IsFavorite"})
end if
if m.top.ItemType <> "" then if m.top.ItemType <> "" then
params.append({ IncludeItemTypes: m.top.ItemType}) params.append({ IncludeItemTypes: m.top.ItemType})
end if end if
@ -53,7 +61,6 @@ sub loadItems()
tmp = CreateObject("roSGNode", "ChannelData") tmp = CreateObject("roSGNode", "ChannelData")
else else
print "Unknown Type: " item.Type print "Unknown Type: " item.Type
end if end if
if tmp <> invalid then if tmp <> invalid then

View File

@ -9,7 +9,8 @@
<field id="metadata" type="associativearray" /> <field id="metadata" type="associativearray" />
<field id="sortField" type="string" value="SortName" /> <field id="sortField" type="string" value="SortName" />
<field id="sortAscending" type="boolean" value="true" /> <field id="sortAscending" type="boolean" value="true" />
<field id="filter" type="string" value="All" />
<!-- Total records available from server--> <!-- Total records available from server-->
<field id="totalRecordCount" type="int" value="-1" /> <field id="totalRecordCount" type="int" value="-1" />
<field id="content" type="array" /> <field id="content" type="array" />

View File

@ -234,7 +234,7 @@ function CreateMovieListGroup(libraryItem)
sidepanel.options = new_options sidepanel.options = new_options
sidepanel.observeField("closeSidePanel", m.port) sidepanel.observeField("closeSidePanel", m.port)
return group return group
end function end function
function CreateMovieDetailsGroup(movie) function CreateMovieDetailsGroup(movie)