Merge pull request #322 from neilsb/home-item-blue-borders

Hide blue background placeholder when Home Item Poster Loaded
This commit is contained in:
Charles Ewert 2020-12-06 12:35:16 -05:00 committed by GitHub
commit 5a0bb8b811
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,41 +1,50 @@
sub itemContentChanged() sub init()
itemData = m.top.itemContent
if itemData = invalid then return
itemData.Title = itemData.name ' Temporarily required while we move from "HomeItem" to "JFContentItem"
m.itemText = m.top.findNode("itemText") m.itemText = m.top.findNode("itemText")
itemPoster = m.top.findNode("itemPoster") m.itemPoster = m.top.findNode("itemPoster")
itemIcon = m.top.findNode("itemIcon") m.itemIcon = m.top.findNode("itemIcon")
itemTextExtra = m.top.findNode("itemTextExtra") m.itemTextExtra = m.top.findNode("itemTextExtra")
m.itemPoster.observeField("loadStatus", "onPosterLoadStatusChanged")
itemPoster.width = itemData.imageWidth
m.itemText.maxWidth = itemData.imageWidth
itemTextExtra.width = itemData.imageWidth
' Randomize the background colors ' Randomize the background colors
m.backdrop = m.top.findNode("backdrop") m.backdrop = m.top.findNode("backdrop")
posterBackgrounds = m.global.constants.poster_bg_pallet posterBackgrounds = m.global.constants.poster_bg_pallet
m.backdrop.color = posterBackgrounds[rnd(posterBackgrounds.count()) - 1] m.backdrop.color = posterBackgrounds[rnd(posterBackgrounds.count()) - 1]
end sub
sub itemContentChanged()
itemData = m.top.itemContent
if itemData = invalid then return
itemData.Title = itemData.name ' Temporarily required while we move from "HomeItem" to "JFContentItem"
m.itemPoster.width = itemData.imageWidth
m.itemText.maxWidth = itemData.imageWidth
m.itemTextExtra.width = itemData.imageWidth
m.itemTextExtra.visible = true
m.backdrop.width = itemData.imageWidth m.backdrop.width = itemData.imageWidth
if itemData.iconUrl <> invalid if itemData.iconUrl <> invalid
itemIcon.uri = itemData.iconUrl m.itemIcon.uri = itemData.iconUrl
end if end if
' Format the Data based on the type of Home Data ' Format the Data based on the type of Home Data
if itemData.type = "CollectionFolder" OR itemData.type = "UserView" OR itemData.type = "Channel" then if itemData.type = "CollectionFolder" OR itemData.type = "UserView" OR itemData.type = "Channel" then
m.itemText.text = itemData.name m.itemText.text = itemData.name
itemPoster.uri = itemData.widePosterURL m.itemPoster.uri = itemData.widePosterURL
return return
end if end if
if itemData.type = "UserView" then if itemData.type = "UserView" then
itemPoster.width = "96" m.itemPoster.width = "96"
itemPoster.height = "96" m.itemPoster.height = "96"
itemPoster.translation = "[192, 88]" m.itemPoster.translation = "[192, 88]"
m.itemText.text = itemData.name m.itemText.text = itemData.name
itemPoster.uri = itemData.widePosterURL m.itemPoster.uri = itemData.widePosterURL
return return
end if end if
@ -44,17 +53,17 @@ sub itemContentChanged()
m.itemText.font.size = 25 m.itemText.font.size = 25
m.itemText.horizAlign = "left" m.itemText.horizAlign = "left"
m.itemText.vertAlign = "bottom" m.itemText.vertAlign = "bottom"
itemTextExtra.visible = true m.itemTextExtra.visible = true
itemTextExtra.font.size = 22 m.itemTextExtra.font.size = 22
if itemData.type = "Episode" then if itemData.type = "Episode" then
m.itemText.text = itemData.json.SeriesName m.itemText.text = itemData.json.SeriesName
if itemData.usePoster = true then if itemData.usePoster = true then
itemPoster.uri = itemData.widePosterURL m.itemPoster.uri = itemData.widePosterURL
else else
itemPoster.uri = itemData.thumbnailURL m.itemPoster.uri = itemData.thumbnailURL
end if end if
' Set Series and Episode Number for Extra Text ' Set Series and Episode Number for Extra Text
@ -69,7 +78,7 @@ sub itemContentChanged()
extraPrefix = extraPrefix + " - " extraPrefix = extraPrefix + " - "
end if end if
itemTextExtra.text = extraPrefix + itemData.name m.itemTextExtra.text = extraPrefix + itemData.name
return return
end if end if
@ -78,9 +87,9 @@ sub itemContentChanged()
' Use best image, but fallback to secondary if it's empty ' Use best image, but fallback to secondary if it's empty
if (itemData.imageWidth = 180 and itemData.posterURL <> "") or itemData.thumbnailURL = "" if (itemData.imageWidth = 180 and itemData.posterURL <> "") or itemData.thumbnailURL = ""
itemPoster.uri = itemData.posterURL m.itemPoster.uri = itemData.posterURL
else else
itemPoster.uri = itemData.thumbnailURL m.itemPoster.uri = itemData.thumbnailURL
end if end if
' Set Release Year and Age Rating for Extra Text ' Set Release Year and Age Rating for Extra Text
@ -95,7 +104,7 @@ sub itemContentChanged()
textExtra = itemData.json.OfficialRating textExtra = itemData.json.OfficialRating
end if end if
end if end if
itemTextExtra.text = textExtra m.itemTextExtra.text = textExtra
return return
end if end if
@ -104,9 +113,9 @@ sub itemContentChanged()
m.itemText.text = itemData.name m.itemText.text = itemData.name
if itemData.imageWidth = 180 if itemData.imageWidth = 180
itemPoster.uri = itemData.posterURL m.itemPoster.uri = itemData.posterURL
else else
itemPoster.uri = itemData.thumbnailURL m.itemPoster.uri = itemData.thumbnailURL
end if end if
return return
end if end if
@ -116,12 +125,12 @@ sub itemContentChanged()
if itemData.usePoster = true then if itemData.usePoster = true then
if itemData.imageWidth = 180 then if itemData.imageWidth = 180 then
itemPoster.uri = itemData.posterURL m.itemPoster.uri = itemData.posterURL
else else
itemPoster.uri = itemData.widePosterURL m.itemPoster.uri = itemData.widePosterURL
end if end if
else else
itemPoster.uri = itemData.thumbnailURL m.itemPoster.uri = itemData.thumbnailURL
end if end if
textExtra = "" textExtra = ""
@ -135,15 +144,15 @@ sub itemContentChanged()
else if itemData.json.Status = "Ended" and itemData.json.EndDate <> invalid else if itemData.json.Status = "Ended" and itemData.json.EndDate <> invalid
textExtra = textExtra + " - " + LEFT(itemData.json.EndDate, 4) textExtra = textExtra + " - " + LEFT(itemData.json.EndDate, 4)
end if end if
itemTextExtra.text = textExtra m.itemTextExtra.text = textExtra
return return
end if end if
if itemData.type = "MusicAlbum" then if itemData.type = "MusicAlbum" then
m.itemText.text = itemData.name m.itemText.text = itemData.name
itemTextExtra.text = itemData.json.AlbumArtist m.itemTextExtra.text = itemData.json.AlbumArtist
itemPoster.uri = itemData.posterURL m.itemPoster.uri = itemData.posterURL
return return
end if end if
@ -162,3 +171,14 @@ sub focusChanged()
end if end if
end sub end sub
'Hide backdrop and icon when poster loaded
sub onPosterLoadStatusChanged()
if m.itemPoster.loadStatus = "ready" and m.itemPoster.uri <> "" then
m.backdrop.visible = false
m.itemIcon.visible = false
else
m.backdrop.visible = true
m.itemIcon.visible = true
end if
end sub