diff --git a/components/ItemGrid/ItemGrid.brs b/components/ItemGrid/ItemGrid.brs index 2d299246..7f902434 100644 --- a/components/ItemGrid/ItemGrid.brs +++ b/components/ItemGrid/ItemGrid.brs @@ -12,6 +12,11 @@ sub init() m.newBackdrop = m.top.findNode("backdropTransition") m.emptyText = m.top.findNode("emptyText") + m.genreList = m.top.findNode("genrelist") + m.genreList.observeField("itemSelected", "onGenreItemSelected") + m.genreData = CreateObject("roSGNode", "ContentNode") + m.genreList.content = m.genreData + m.swapAnimation = m.top.findNode("backroundSwapAnimation") m.swapAnimation.observeField("state", "swapDone") @@ -74,6 +79,12 @@ sub init() end if end sub +' +'Genre Item Selected +sub onGenreItemSelected() + m.top.selectedItem = m.genreList.content.getChild(m.genreList.rowItemSelected[0]).getChild(m.genreList.rowItemSelected[1]) +end sub + ' 'Load initial set of Data sub loadInitialItems() @@ -287,6 +298,14 @@ sub setTvShowsOptions(options) { "Title": tr("Played"), "Name": "Played" }, { "Title": tr("Unplayed"), "Name": "Unplayed" } ] + + if isValid(m.view) + if LCase(m.options.view) = "genres" or LCase(m.view) = "genres" + options.sort = [{ "Title": tr("TITLE"), "Name": "SortName" }] + options.filter = [] + end if + end if + end sub ' Set Live TV view, sort, and filter options @@ -430,10 +449,32 @@ sub ItemDataLoaded(msg) return end if + if m.loadItemsTask.view = "Genres" + ' Reset genre list data + m.genreData.removeChildren(m.genreData.getChildren(-1, 0)) + + for each item in itemData + m.genreData.appendChild(item) + end for + + m.itemGrid.opacity = "0" + m.genreList.opacity = "1" + + m.itemGrid.setFocus(false) + m.genreList.setFocus(true) + + m.loading = false + m.spinner.visible = false + return + end if + for each item in itemData m.data.appendChild(item) end for + m.itemGrid.opacity = "1" + m.genreList.opacity = "0" + 'Update the stored counts m.loadedItems = m.itemGrid.content.getChildCount() m.loadedRows = m.loadedItems / m.itemGrid.numColumns @@ -445,6 +486,7 @@ sub ItemDataLoaded(msg) end if m.itemGrid.setFocus(true) + m.genreList.setFocus(false) m.spinner.visible = false end sub @@ -652,7 +694,10 @@ sub optionsClosed() m.itemGrid.content = m.data loadInitialItems() end if - m.itemGrid.setFocus(true) + + m.itemGrid.setFocus(m.itemGrid.opacity = 1) + m.genreList.setFocus(m.genreList.opacity = 1) + if m.tvGuide <> invalid m.tvGuide.lastFocus.setFocus(true) end if @@ -688,13 +733,19 @@ end sub function onKeyEvent(key as string, press as boolean) as boolean if not press then return false - topGrp = m.top.findNode("itemGrid") + + if m.itemGrid.opacity = 1 + topGrp = m.itemGrid + else + topGrp = m.genreList + end if searchGrp = m.top.findNode("voiceBox") if key = "left" and searchGrp.isinFocusChain() topGrp.setFocus(true) searchGrp.setFocus(false) end if + if key = "options" if m.options.visible = true m.options.visible = false @@ -780,14 +831,16 @@ function onKeyEvent(key as string, press as boolean) as boolean end function sub updateTitle() - if m.filter = "All" - m.top.overhangTitle = m.top.parentItem.title - else if m.filter = "Favorites" + m.top.overhangTitle = m.top.parentItem.title + + if m.filter = "Favorites" m.top.overhangTitle = m.top.parentItem.title + " " + tr("(Favorites)") end if + if m.voiceBox.text <> "" m.top.overhangTitle = m.top.parentItem.title + tr(" (Filtered by ") + m.loadItemsTask.searchTerm + ")" end if + if m.top.alphaSelected <> "" m.top.overhangTitle = m.top.parentItem.title + tr(" (Filtered by ") + m.loadItemsTask.nameStartsWith + ")" end if @@ -801,14 +854,18 @@ sub updateTitle() if m.options.view = "Networks" or m.view = "Networks" m.top.overhangTitle = "%s (%s)".Format(m.top.parentItem.title, tr("Networks")) end if + if m.options.view = "Studios" or m.view = "Studios" m.top.overhangTitle = "%s (%s)".Format(m.top.parentItem.title, tr("Studios")) end if + if m.options.view = "Genres" or m.view = "Genres" m.top.overhangTitle = "%s (%s)".Format(m.top.parentItem.title, tr("Genres")) end if + actInt = m.itemGrid.itemFocused + 1 - if m.showItemCount and m.loadItemsTask.totalRecordCount > 0 + + if m.showItemCount and m.loadItemsTask.totalRecordCount > 0 and m.options.view <> "Genres" and m.view <> "Genres" m.top.overhangTitle += " (" + tr("%1 of %2").Replace("%1", actInt.toStr()).Replace("%2", m.loadItemsTask.totalRecordCount.toStr()) + ")" end if diff --git a/components/ItemGrid/ItemGrid.xml b/components/ItemGrid/ItemGrid.xml index ec528c44..9fcd213b 100644 --- a/components/ItemGrid/ItemGrid.xml +++ b/components/ItemGrid/ItemGrid.xml @@ -3,18 +3,8 @@ - - + + -