Change playlist view cell to avoid execution timeout
This commit is contained in:
1 parent
9baa132ca3
commit
837386b6e0
2 files changed
+18
-20
No files matched your search
@@ -2,13 +2,6 @@ import "pkg:/source/utils/TimeUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
function Init()
|
||||
FindChildren()
|
||||
end function
|
||||
|
||||
function FindChildren()
|
||||
m.titleLabel = m.top.findNode("titleLabel")
|
||||
m.authorLabel = m.top.findNode("authorLabel")
|
||||
m.thumbnail = m.top.findNode("thumbnail")
|
||||
m.durationRect = m.top.FindNode("durationRect")
|
||||
m.durationLabel = m.top.FindNode("durationLabel")
|
||||
end function
|
||||
@@ -20,29 +13,29 @@ function OnContentSet() as void
|
||||
return
|
||||
end if
|
||||
|
||||
if m.titleLabel = invalid
|
||||
FindChildren()
|
||||
end if
|
||||
m.top.title = content.title
|
||||
m.top.author = content.author
|
||||
m.top.thumbnailUri = content.thumbnail
|
||||
|
||||
m.titleLabel.text = content.title
|
||||
m.authorLabel.text = content.author
|
||||
|
||||
m.thumbnail.uri = content.thumbnail
|
||||
if ValidInt(content.lengthSeconds) <> 0
|
||||
SetDurationText(content.lengthText)
|
||||
m.durationRect.visible = true
|
||||
m.top.durationRectVisible = true
|
||||
else
|
||||
m.durationRect.visible = false
|
||||
m.top.durationRectVisible = false
|
||||
end if
|
||||
end function
|
||||
|
||||
function SetDurationText(text as string)
|
||||
function SetDurationText(text as string) as void
|
||||
m.top.duration = text
|
||||
|
||||
label = m.durationLabel
|
||||
rect = m.durationRect
|
||||
|
||||
rectParent = rect.getParent()
|
||||
if label = invalid or rect = invalid
|
||||
return
|
||||
end if
|
||||
|
||||
label.text = text
|
||||
rectParent = rect.getParent()
|
||||
size = label.localBoundingRect()
|
||||
|
||||
rect.width = size.width + 16
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
<component name="PlaylistViewCell" extends="Group">
|
||||
<interface>
|
||||
<field id="itemContent" type="node" onChange="OnContentSet" />
|
||||
<field id="title" type="string" alias="titleLabel.text" />
|
||||
<field id="author" type="string" alias="authorLabel.text" />
|
||||
<field id="thumbnailUri" type="uri" alias="thumbnailPoster.uri" />
|
||||
<field id="duration" type="string" alias="durationLabel.text" />
|
||||
<field id="durationRectVisible" type="boolean" alias="durationRect.visible" />
|
||||
</interface>
|
||||
<children>
|
||||
<Poster
|
||||
id="thumbnail"
|
||||
id="thumbnailPoster"
|
||||
loadDisplayMode="scaleToZoom"
|
||||
width="190"
|
||||
height="106"
|
||||
|
||||
Reference in new issue
Block a user