Skip to content

Commit

Permalink
Merge pull request #1515 from cewert/add-more-loading-spinners
Browse files Browse the repository at this point in the history
Convert app to use one spinner attached to JFScene + resize spinner
  • Loading branch information
1hitsong authored Nov 30, 2023
2 parents b3834bd + a8256c2 commit 39448b7
Show file tree
Hide file tree
Showing 32 changed files with 172 additions and 131 deletions.
19 changes: 8 additions & 11 deletions components/ItemGrid/ItemGrid.bs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ sub init()
'set inital counts for overhang before content is loaded.
m.loadItemsTask.totalRecordCount = 0

m.spinner = m.top.findNode("spinner")
m.spinner.visible = true

m.Alpha = m.top.findNode("AlphaMenu")
m.AlphaSelected = m.top.findNode("AlphaSelected")

Expand All @@ -92,7 +89,7 @@ end sub
'Load initial set of Data
sub loadInitialItems()
m.loadItemsTask.control = "stop"
m.spinner.visible = true
startLoadingSpinner()

if m.top.parentItem.json.Type = "CollectionFolder" 'or m.top.parentItem.json.Type = "Folder"
m.top.HomeLibraryItem = m.top.parentItem.Id
Expand Down Expand Up @@ -238,7 +235,7 @@ sub loadInitialItems()
end if

m.loadItemsTask.observeField("content", "ItemDataLoaded")
m.spinner.visible = true
startLoadingSpinner(false)
m.loadItemsTask.control = "RUN"
SetUpOptions()
end sub
Expand Down Expand Up @@ -450,6 +447,7 @@ end sub
'
'Handle loaded data, and add to Grid
sub ItemDataLoaded(msg)
stopLoadingSpinner()
m.top.alphaActive = false
itemData = msg.GetData()
m.loadItemsTask.unobserveField("content")
Expand All @@ -475,7 +473,7 @@ sub ItemDataLoaded(msg)
m.genreList.setFocus(true)

m.loading = false
m.spinner.visible = false
stopLoadingSpinner()
return
end if

Expand All @@ -498,7 +496,7 @@ sub ItemDataLoaded(msg)

m.itemGrid.setFocus(true)
m.genreList.setFocus(false)
m.spinner.visible = false
stopLoadingSpinner()
end sub

'
Expand Down Expand Up @@ -571,7 +569,7 @@ end sub
'
'Load next set of items
sub loadMoreData()
m.spinner.visible = true
startLoadingSpinner(false)
if m.Loading = true then return
m.Loading = true
m.loadItemsTask.startIndex = m.loadedItems
Expand All @@ -594,7 +592,7 @@ sub onItemalphaSelected()
m.loadItemsTask.searchTerm = ""
m.VoiceBox.text = ""
m.loadItemsTask.nameStartsWith = m.alpha.itemAlphaSelected
m.spinner.visible = true
startLoadingSpinner(false)
loadInitialItems()
end if
end sub
Expand All @@ -609,7 +607,7 @@ sub onvoiceFilter()
m.loadItemsTask.NameStartsWith = " "
m.loadItemsTask.searchTerm = m.voiceBox.text
m.loadItemsTask.recursive = true
m.spinner.visible = true
startLoadingSpinner(false)
loadInitialItems()
end if
end sub
Expand Down Expand Up @@ -845,7 +843,6 @@ function onKeyEvent(key as string, press as boolean) as boolean
end if

if key = "replay"
m.spinner.visible = true
m.loadItemsTask.searchTerm = ""
m.loadItemsTask.nameStartsWith = ""
m.voiceBox.text = ""
Expand Down
1 change: 0 additions & 1 deletion components/ItemGrid/ItemGrid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<Button id="micButton" maxWidth="20" translation="[20, 120]" iconUri="pkg:/images/icons/mic_icon.png" />
<Label translation="[0,540]" id="emptyText" font="font:LargeSystemFont" width="1910" horizAlign="center" vertAlign="center" height="64" visible="false" />
<ItemGridOptions id="options" visible="false" />
<Spinner id="spinner" translation="[900, 450]" />
<Animation id="backroundSwapAnimation" duration="1" repeat="false" easeFunction="linear">
<FloatFieldInterpolator id="fadeinLoading" key="[0.0, 1.0]" keyValue="[ 0.00, 0.25 ]" fieldToInterp="backdropTransition.opacity" />
<FloatFieldInterpolator id="fadeoutLoaded" key="[0.0, 1.0]" keyValue="[ 0.25, 0.00 ]" fieldToInterp="backdrop.opacity" />
Expand Down
15 changes: 4 additions & 11 deletions components/ItemGrid/MovieLibraryView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ sub setupNodes()
m.selectedMovieOfficialRating = m.top.findNode("selectedMovieOfficialRating")
m.movieLogo = m.top.findNode("movieLogo")
m.swapAnimation = m.top.findNode("backroundSwapAnimation")
m.spinner = m.top.findNode("spinner")
m.Alpha = m.top.findNode("AlphaMenu")
m.AlphaSelected = m.top.findNode("AlphaSelected")
m.micButton = m.top.findNode("micButton")
Expand Down Expand Up @@ -83,8 +82,6 @@ sub init()
'set inital counts for overhang before content is loaded.
m.loadItemsTask.totalRecordCount = 0

m.spinner.visible = true

'Get reset folder setting
m.resetGrid = m.global.session.user.settings["itemgrid.reset"]

Expand Down Expand Up @@ -117,7 +114,7 @@ end sub
'Load initial set of Data
sub loadInitialItems()
m.loadItemsTask.control = "stop"
m.spinner.visible = true
startLoadingSpinner(false)

if m.top.parentItem.json.Type = "CollectionFolder"
m.top.HomeLibraryItem = m.top.parentItem.Id
Expand Down Expand Up @@ -219,7 +216,6 @@ sub loadInitialItems()
end if

m.loadItemsTask.observeField("content", "ItemDataLoaded")
m.spinner.visible = true
m.loadItemsTask.control = "RUN"

m.getFiltersTask.observeField("filters", "FilterDataLoaded")
Expand Down Expand Up @@ -436,7 +432,7 @@ sub ItemDataLoaded(msg)
m.genreList.setFocus(true)

m.loading = false
m.spinner.visible = false
stopLoadingSpinner()
' Return focus to options menu if it was opened while library was loading
if m.options.visible
m.options.setFocus(true)
Expand Down Expand Up @@ -486,7 +482,7 @@ sub ItemDataLoaded(msg)
m.emptyText.visible = true
end if

m.spinner.visible = false
stopLoadingSpinner()
' Return focus to options menu if it was opened while library was loading
if m.options.visible
m.options.setFocus(true)
Expand Down Expand Up @@ -691,7 +687,7 @@ end sub
'
'Load next set of items
sub loadMoreData()
m.spinner.visible = true
startLoadingSpinner(false)
if m.Loading = true then return
m.Loading = true
m.loadItemsTask.startIndex = m.loadedItems
Expand Down Expand Up @@ -736,7 +732,6 @@ sub onItemalphaSelected()
m.loadItemsTask.searchTerm = ""
m.VoiceBox.text = ""
m.loadItemsTask.nameStartsWith = m.alpha.itemAlphaSelected
m.spinner.visible = true
loadInitialItems()
end if
end sub
Expand All @@ -751,7 +746,6 @@ sub onvoiceFilter()
m.loadItemsTask.NameStartsWith = " "
m.loadItemsTask.searchTerm = m.voiceBox.text
m.loadItemsTask.recursive = true
m.spinner.visible = true
loadInitialItems()
end if
end sub
Expand Down Expand Up @@ -924,7 +918,6 @@ function onKeyEvent(key as string, press as boolean) as boolean
end if

if key = "replay"
m.spinner.visible = true
m.loadItemsTask.searchTerm = ""
m.loadItemsTask.nameStartsWith = ""
m.voiceBox.text = ""
Expand Down
1 change: 0 additions & 1 deletion components/ItemGrid/MovieLibraryView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<Button id="micButton" maxWidth="20" translation="[20, 120]" iconUri="pkg:/images/icons/mic_icon.png" />
<Label translation="[0,540]" id="emptyText" font="font:LargeSystemFont" width="1910" horizAlign="center" vertAlign="center" height="64" visible="false" />
<ItemGridOptions id="options" visible="false" />
<Spinner id="spinner" translation="[900, 450]" />
<Animation id="backroundSwapAnimation" duration="1" repeat="false" easeFunction="linear">
<FloatFieldInterpolator id="fadeinLoading" key="[0.0, 1.0]" keyValue="[ 0.00, 1.00 ]" fieldToInterp="backdropTransition.opacity" />
<FloatFieldInterpolator id="fadeoutLoaded" key="[0.0, 1.0]" keyValue="[ 1.00, 0.00 ]" fieldToInterp="backdrop.opacity" />
Expand Down
15 changes: 3 additions & 12 deletions components/ItemGrid/MusicLibraryView.bs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ sub setupNodes()
m.selectedArtistGenres = m.top.findNode("selectedArtistGenres")
m.artistLogo = m.top.findNode("artistLogo")
m.swapAnimation = m.top.findNode("backroundSwapAnimation")
m.spinner = m.top.findNode("spinner")
m.Alpha = m.top.findNode("AlphaMenu")
m.AlphaSelected = m.top.findNode("AlphaSelected")
m.micButton = m.top.findNode("micButton")
Expand Down Expand Up @@ -77,8 +76,6 @@ sub init()
'set inital counts for overhang before content is loaded.
m.loadItemsTask.totalRecordCount = 0

m.spinner.visible = true

'Get reset folder setting
m.resetGrid = m.global.session.user.settings["itemgrid.reset"]

Expand Down Expand Up @@ -111,7 +108,7 @@ end sub
'Load initial set of Data
sub loadInitialItems()
m.loadItemsTask.control = "stop"
m.spinner.visible = true
startLoadingSpinner()

if LCase(m.top.parentItem.json.Type) = "collectionfolder"
m.top.HomeLibraryItem = m.top.parentItem.Id
Expand Down Expand Up @@ -204,7 +201,6 @@ sub loadInitialItems()
end if

m.loadItemsTask.observeField("content", "ItemDataLoaded")
m.spinner.visible = true
m.loadItemsTask.control = "RUN"
SetUpOptions()
end sub
Expand Down Expand Up @@ -326,6 +322,7 @@ end sub
'
'Handle loaded data, and add to Grid
sub ItemDataLoaded(msg)
stopLoadingSpinner()
m.top.alphaActive = false
itemData = msg.GetData()
m.loadItemsTask.unobserveField("content")
Expand All @@ -351,7 +348,6 @@ sub ItemDataLoaded(msg)
m.loadedRows = m.loadedItems / m.genreList.numColumns

m.loading = false
m.spinner.visible = false
return
end if

Expand All @@ -374,8 +370,6 @@ sub ItemDataLoaded(msg)
m.emptyText.text = tr("NO_ITEMS").Replace("%1", m.top.parentItem.Type)
m.emptyText.visible = true
end if

m.spinner.visible = false
end sub

'
Expand Down Expand Up @@ -556,7 +550,7 @@ end sub
'
'Load next set of items
sub loadMoreData()
m.spinner.visible = true
startLoadingSpinner(false)
if m.Loading = true then return
m.Loading = true
m.loadItemsTask.startIndex = m.loadedItems
Expand Down Expand Up @@ -612,7 +606,6 @@ sub onItemalphaSelected()
m.loadItemsTask.searchTerm = ""
m.VoiceBox.text = ""
m.loadItemsTask.nameStartsWith = m.alpha.itemAlphaSelected
m.spinner.visible = true
loadInitialItems()
end if
end sub
Expand All @@ -627,7 +620,6 @@ sub onvoiceFilter()
m.loadItemsTask.NameStartsWith = " "
m.loadItemsTask.searchTerm = m.voiceBox.text
m.loadItemsTask.recursive = true
m.spinner.visible = true
loadInitialItems()
end if
end sub
Expand Down Expand Up @@ -787,7 +779,6 @@ function onKeyEvent(key as string, press as boolean) as boolean
end if

if key = "replay"
m.spinner.visible = true
m.loadItemsTask.searchTerm = ""
m.loadItemsTask.nameStartsWith = ""
m.voiceBox.text = ""
Expand Down
1 change: 0 additions & 1 deletion components/ItemGrid/MusicLibraryView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<Button id="micButton" maxWidth="20" translation="[20, 120]" iconUri="pkg:/images/icons/mic_icon.png" />
<Label translation="[0,540]" id="emptyText" font="font:LargeSystemFont" width="1910" horizAlign="center" vertAlign="center" height="64" visible="false" />
<ItemGridOptions id="options" visible="false" />
<Spinner id="spinner" translation="[900, 450]" />
<Animation id="backroundSwapAnimation" duration="1" repeat="false" easeFunction="linear">
<FloatFieldInterpolator id="fadeinLoading" key="[0.0, 1.0]" keyValue="[ 0.00, 1.00 ]" fieldToInterp="backdropTransition.opacity" />
<FloatFieldInterpolator id="fadeoutLoaded" key="[0.0, 1.0]" keyValue="[ 1.00, 0.00 ]" fieldToInterp="backdrop.opacity" />
Expand Down
21 changes: 21 additions & 0 deletions components/JFScene.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@ import "pkg:/source/utils/misc.bs"
sub init()
m.top.backgroundColor = "#262626" '"#101010"
m.top.backgroundURI = ""
m.spinner = m.top.findNode("spinner")
end sub

' Triggered when the isLoading boolean component field is changed
sub isLoadingChanged()
m.spinner.visible = m.top.isLoading
end sub

' Triggered when the disableRemote boolean component field is changed
sub disableRemoteChanged()
if m.top.disableRemote
dialog = createObject("roSGNode", "ProgressDialog")
dialog.id = "invisibiledialog"
dialog.visible = false
dialog.opacity = 0
m.top.dialog = dialog
else
if isValid(m.top.dialog)
m.top.dialog.close = true
end if
end if
end sub

function onKeyEvent(key as string, press as boolean) as boolean
Expand Down
3 changes: 3 additions & 0 deletions components/JFScene.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
<children>
<Group id="content" />
<JFOverhang id="overhang" />
<Spinner id="spinner" translation="[897, 477]" visible="false" />
</children>
<interface>
<field id="disableRemote" type="boolean" value="false" onchange="disableRemoteChanged" />
<field id="isLoading" type="boolean" value="false" onchange="isLoadingChanged" />
<field id="exit" type="boolean" alwaysNotify="true" />
</interface>
</component>
2 changes: 1 addition & 1 deletion components/Spinner.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ sub init()
m.top.poster.uri = "pkg:/images/spinner.png"
m.top.control = "start"
m.top.clockwise = true
m.top.spinInterval = 3
m.top.spinInterval = 1
end sub
5 changes: 2 additions & 3 deletions components/config/SetServerScreen.bs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ sub init()
m.log = log.Logger("SetServerScreen")
m.top.setFocus(true)

m.spinner = m.top.findNode("spinner")
m.serverPicker = m.top.findNode("serverPicker")
m.serverUrlTextbox = m.top.findNode("serverUrlTextbox")
m.serverUrlContainer = m.top.findNode("serverUrlContainer")
Expand Down Expand Up @@ -76,7 +75,7 @@ sub ScanForServers()
'run the task
m.ssdpScanner.observeField("content", "ScanForServersComplete")
m.ssdpScanner.control = "RUN"
m.spinner.visible = true
startLoadingSpinner(false)
end sub

sub ScanForServersComplete(event)
Expand Down Expand Up @@ -109,7 +108,7 @@ sub ScanForServersComplete(event)
end if

m.serverPicker.content = items
m.spinner.visible = false
stopLoadingSpinner()

'if we have at least one server, focus on the server picker
if m.servers.Count() > 0
Expand Down
1 change: 0 additions & 1 deletion components/config/SetServerScreen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
</LayoutGroup>
<!--background for server picker-->
<Rectangle color="0x00000020" width="1620" height="400">
<Spinner id="spinner" translation="[717, 136]" />
<MarkupList id="serverPicker" translation="[50, 20]" itemComponentName="JFServer" itemSpacing="[0, 10]" itemSize="[1520, 100]" numRows="3" vertFocusAnimationStyle="floatingFocus" />
</Rectangle>

Expand Down
Loading

0 comments on commit 39448b7

Please sign in to comment.