2023-10-03 16:11:25 +00:00
|
|
|
import "pkg:/source/api/Items.bs"
|
|
|
|
import "pkg:/source/api/baserequest.bs"
|
|
|
|
import "pkg:/source/utils/config.bs"
|
|
|
|
import "pkg:/source/api/Image.bs"
|
|
|
|
import "pkg:/source/utils/deviceCapabilities.bs"
|
2023-05-03 21:21:04 +00:00
|
|
|
|
2019-05-03 13:27:51 +00:00
|
|
|
sub init()
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.optionsAvailable = false
|
2022-09-05 06:50:13 +00:00
|
|
|
m.searchSpinner = m.top.findnode("searchSpinner")
|
|
|
|
m.searchSelect = m.top.findnode("searchSelect")
|
|
|
|
m.searchTask = CreateObject("roSGNode", "SearchTask")
|
|
|
|
|
|
|
|
'set label text
|
|
|
|
m.searchHelpText = m.top.findNode("SearchHelpText")
|
|
|
|
m.searchHelpText.text = tr("You can search for Titles, People, Live TV Channels and more")
|
|
|
|
|
2022-05-30 12:57:40 +00:00
|
|
|
end sub
|
2022-09-05 06:50:13 +00:00
|
|
|
|
|
|
|
sub searchMedias()
|
|
|
|
query = m.top.searchAlpha
|
|
|
|
'if user deletes the search string hide the spinner
|
|
|
|
if query.len() = 0
|
|
|
|
m.searchSpinner.visible = false
|
|
|
|
end if
|
|
|
|
'if search task is running and user selectes another letter stop the search and load the next letter
|
|
|
|
m.searchTask.control = "stop"
|
|
|
|
if query <> invalid and query <> ""
|
|
|
|
m.searchSpinner.visible = true
|
|
|
|
end if
|
|
|
|
m.searchTask.observeField("results", "loadResults")
|
|
|
|
m.searchTask.query = query
|
|
|
|
m.top.overhangTitle = tr("Search") + ": " + query
|
|
|
|
m.searchTask.control = "RUN"
|
|
|
|
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub loadResults()
|
|
|
|
m.searchTask.unobserveField("results")
|
|
|
|
|
|
|
|
m.searchSpinner.visible = false
|
|
|
|
m.searchSelect.itemdata = m.searchTask.results
|
|
|
|
m.searchSelect.query = m.top.SearchAlpha
|
|
|
|
m.searchHelpText.visible = false
|
2023-10-31 20:11:56 +00:00
|
|
|
if m.searchTask.results.TotalRecordCount = 0
|
|
|
|
' make sure focus is on the keyboard
|
|
|
|
if m.searchSelect.isinFocusChain()
|
|
|
|
m.searchAlphabox.setFocus(true)
|
|
|
|
end if
|
|
|
|
return
|
|
|
|
end if
|
2022-09-05 06:50:13 +00:00
|
|
|
m.searchAlphabox = m.top.findnode("searchResults")
|
|
|
|
m.searchAlphabox.translation = "[470, 85]"
|
|
|
|
end sub
|
|
|
|
|
|
|
|
function onKeyEvent(key as string, press as boolean) as boolean
|
|
|
|
|
|
|
|
m.searchAlphabox = m.top.findNode("search_Key")
|
|
|
|
if m.searchAlphabox.textEditBox.hasFocus()
|
|
|
|
m.searchAlphabox.textEditBox.translation = "[0, -150]"
|
|
|
|
else
|
|
|
|
m.searchAlphabox.textEditBox.translation = "[0, 0]"
|
|
|
|
end if
|
|
|
|
|
2022-11-29 19:14:32 +00:00
|
|
|
if key = "left" and m.searchSelect.isinFocusChain()
|
2022-09-05 06:50:13 +00:00
|
|
|
m.searchAlphabox.setFocus(true)
|
|
|
|
return true
|
2023-10-31 19:26:54 +00:00
|
|
|
else if key = "right" and m.searchSelect.content <> invalid and m.searchSelect.content.getChildCount() > 0
|
2022-09-05 06:50:13 +00:00
|
|
|
m.searchSelect.setFocus(true)
|
|
|
|
return true
|
2023-10-31 19:08:03 +00:00
|
|
|
else if key = "play" and m.searchSelect.isinFocusChain() and m.searchSelect.rowItemFocused.count() > 0
|
2023-10-29 02:36:35 +00:00
|
|
|
print "play was pressed from search results"
|
|
|
|
if m.searchSelect.rowItemFocused <> invalid
|
2023-10-31 20:11:56 +00:00
|
|
|
selectedContent = m.searchSelect.content.getChild(m.searchSelect.rowItemFocused[0])
|
|
|
|
if selectedContent <> invalid
|
|
|
|
selectedItem = selectedContent.getChild(m.searchSelect.rowItemFocused[1])
|
|
|
|
if selectedItem <> invalid
|
|
|
|
m.top.quickPlayNode = selectedItem
|
|
|
|
return true
|
|
|
|
end if
|
|
|
|
end if
|
2023-10-29 02:36:35 +00:00
|
|
|
end if
|
2022-09-05 06:50:13 +00:00
|
|
|
end if
|
|
|
|
return false
|
|
|
|
|
|
|
|
end function
|