Merge pull request #246 from neilsb/grid-update-failed-images

Remove failed & loading images for Grid Items
This commit is contained in:
Anthony Lavado 2020-07-12 12:15:26 -04:00 committed by GitHub
commit 19caa41a05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 8 deletions

View File

@ -1,13 +1,21 @@
sub init()
m.posterMask = m.top.findNode("posterMask")
m.itemPoster = m.top.findNode("itemPoster")
m.posterText = m.top.findNode("posterText")
m.itemText = m.top.findNode("itemText")
m.backdrop = m.top.findNode("backdrop")
m.itemPoster.observeField("loadStatus", "onPosterLoadStatusChanged")
m.itemText.translation = [0, m.itemPoster.height + 7]
end sub
sub itemContentChanged()
' Set Randmom background colors from pallet
posterBackgrounds = m.global.poster_bg_pallet
m.backdrop.color = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
itemData = m.top.itemContent
if itemData = invalid then return
@ -15,18 +23,17 @@ sub itemContentChanged()
if itemData.type = "Movie" then
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
return
else if itemData.type = "Series" then
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
return
else if itemData.type = "Boxset" then
itemPoster.uri = itemData.PosterUrl
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
return
else
print "Unhandled Item Type: " + itemData.type
end if
print "Unhandled Item Type: " + itemData.type
m.posterText.text = m.itemText.text
end sub
@ -43,8 +50,18 @@ sub focusChanged()
if m.top.itemHasFocus = true then
m.itemText.visible = true
m.itemText.repeatCount = -1
else
m.itemText.visible = false
m.itemText.repeatCount = 0
end if
end sub
'Hide backdrop and text when poster loaded
sub onPosterLoadStatusChanged()
if m.itemPoster.loadStatus = "ready" then
m.backdrop.visible = false
m.posterText.visible = false
end if
end sub

View File

@ -2,7 +2,9 @@
<component name="GridItem" extends="Group">
<children>
<maskGroup id="posterMask" maskUri="pkg:/images/postermask.png" scaleRotateCenter="[145, 212.5]" scale="[0.85,0.85]" >
<Poster id="itemPoster" width="290" height="425" loadDisplayMode="scaleToZoom" loadingBitmapUri="pkg:/images/PosterLoading.png" failedBitmapUri="pkg:/images/PosterFailed.png" />
<Rectangle id="backdrop" width="290" height="425" />
<Poster id="itemPoster" width="290" height="425" loadDisplayMode="scaleToZoom" />
<Label id="posterText" width="280" height="415" translation="[5,5]" horizAlign="center" vertAlign="center" ellipsizeOnBoundary="true" wrap="true" />
</maskGroup>
<ScrollingLabel id="itemText" horizAlign="center" font="font:SmallSystemFont" maxWidth="290" repeatCount="-1" visible="false" />
</children>

View File

@ -6,7 +6,7 @@ sub init()
m.backdrop = m.top.findNode("backdrop")
' Randmomise the background colors
posterBackgrounds = [ "#5ccea9", "#d2b019", "#dd452b", "#338abb", "#6b689d" ]
posterBackgrounds = m.global.poster_bg_pallet
m.backdrop.color = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
updateSize()

View File

@ -18,7 +18,7 @@ sub itemContentChanged()
' Randmomise the background colors
m.backdrop = m.top.findNode("backdrop")
posterBackgrounds = [ "#5ccea9", "#d2b019", "#dd452b", "#338abb", "#6b689d" ]
posterBackgrounds = m.global.poster_bg_pallet
m.backdrop.color = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
m.backdrop.width = imageWidth

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -5,6 +5,11 @@ sub Main()
' The main function that runs when the application is launched.
m.screen = CreateObject("roSGScreen")
' Set Global Constants
m.global = m.screen.getGlobalNode()
m.global.addFields({ poster_bg_pallet : [ "#00455c", "#44bae1", "#00a4db", "#1c4c5c", "#007ea8" ] })
m.port = CreateObject("roMessagePort")
m.screen.setMessagePort(m.port)
m.scene = m.screen.CreateScene("JFScene")