mirror of
https://github.com/jellyfin/jellyfin-roku.git
synced 2024-11-30 18:01:04 +00:00
Merge pull request #591 from neilsb/add-screen-events
This commit is contained in:
commit
c090651fe0
16
components/JFScreen.brs
Normal file
16
components/JFScreen.brs
Normal file
@ -0,0 +1,16 @@
|
||||
' Function called when the screen is displayed by the screen manager
|
||||
' It is expected that screens override this function to handle focus
|
||||
' managmenet and any other actions required on screen shown
|
||||
sub OnScreenShown()
|
||||
if m.top.lastFocus <> invalid
|
||||
m.top.lastFocus.setFocus(true)
|
||||
else
|
||||
m.top.setFocus(true)
|
||||
end if
|
||||
end sub
|
||||
|
||||
' Function called when the screen is hidden by the screen manager
|
||||
' It is expected that screens override this function if required,
|
||||
' to handle focus any actions required on the screen being hidden
|
||||
sub OnScreenHidden()
|
||||
end sub
|
8
components/JFScreen.xml
Normal file
8
components/JFScreen.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<component name="JFScreen" extends="JFGroup">
|
||||
<interface>
|
||||
<function name="OnScreenShown" />
|
||||
<function name="OnScreenHidden" />
|
||||
</interface>
|
||||
<script type="text/brightscript" uri="JFScreen.brs" />
|
||||
</component>
|
@ -28,6 +28,11 @@ sub pushScene(newGroup)
|
||||
end if
|
||||
|
||||
currentGroup.visible = false
|
||||
|
||||
if currentGroup.isSubType("JFScreen")
|
||||
currentGroup.callFunc("OnScreenHidden")
|
||||
end if
|
||||
|
||||
end if
|
||||
|
||||
m.groups.push(newGroup)
|
||||
@ -38,6 +43,10 @@ sub pushScene(newGroup)
|
||||
m.content.appendChild(newGroup)
|
||||
end if
|
||||
|
||||
if newGroup.isSubType("JFScreen")
|
||||
newGroup.callFunc("OnScreenShown")
|
||||
end if
|
||||
|
||||
'observe info about new group, set overhang title, etc.
|
||||
if newGroup.isSubType("JFGroup")
|
||||
registerOverhangData(newGroup)
|
||||
@ -65,6 +74,12 @@ sub popScene()
|
||||
' Stop video to make sure app communicates stop playstate to server
|
||||
group.control = "stop"
|
||||
end if
|
||||
|
||||
group.visible = false
|
||||
|
||||
if group.isSubType("JFScreen")
|
||||
group.callFunc("OnScreenHidden")
|
||||
end if
|
||||
else
|
||||
' Exit app if for some reason we don't have anything on the stack
|
||||
m.scene.exit = true
|
||||
@ -86,11 +101,16 @@ sub popScene()
|
||||
|
||||
m.content.replaceChild(group, 0)
|
||||
|
||||
' Restore focus
|
||||
if group.lastFocus <> invalid
|
||||
group.lastFocus.setFocus(true)
|
||||
if group.isSubType("JFScreen")
|
||||
group.callFunc("OnScreenShown")
|
||||
else
|
||||
group.setFocus(true)
|
||||
|
||||
' Restore focus
|
||||
if group.lastFocus <> invalid
|
||||
group.lastFocus.setFocus(true)
|
||||
else
|
||||
group.setFocus(true)
|
||||
end if
|
||||
end if
|
||||
else
|
||||
' Exit app if the stack is empty after removing group
|
||||
|
@ -14,10 +14,17 @@ sub init()
|
||||
|
||||
m.buttonGrp = m.top.findNode("buttons")
|
||||
m.buttonGrp.setFocus(true)
|
||||
m.top.lastFocus = m.buttonGrp
|
||||
|
||||
m.top.observeField("itemContent", "itemContentChanged")
|
||||
end sub
|
||||
|
||||
sub OnScreenShown()
|
||||
' set focus to button group
|
||||
m.buttonGrp.setFocus(true)
|
||||
end sub
|
||||
|
||||
|
||||
sub itemContentChanged()
|
||||
' Updates video metadata
|
||||
item = m.top.itemContent
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<component name="MovieDetails" extends="JFGroup">
|
||||
<component name="MovieDetails" extends="JFScreen">
|
||||
<children>
|
||||
<LayoutGroup id="main_group" layoutDirection="horiz" itemSpacings="[30]">
|
||||
<Poster id="moviePoster"
|
||||
|
@ -231,6 +231,10 @@ sub Main (args as dynamic) as void
|
||||
if video <> invalid
|
||||
sceneManager.callFunc("pushScene", video)
|
||||
end if
|
||||
|
||||
if group.lastFocus <> invalid
|
||||
group.lastFocus.setFocus(true)
|
||||
end if
|
||||
else if btn <> invalid and btn.id = "watched-button"
|
||||
movie = group.itemContent
|
||||
if movie.watched
|
||||
|
Loading…
Reference in New Issue
Block a user