Sub showMoviesScreen()
dlg = CreateObject("roOneLineDialog")
dlg.setTitle("Loading Collection")
dlg.showBusyAnimation()
dlg.show()
screen = CreateObject("roGridScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetGridStyle("flat-portrait")
screen.SetDescriptionVisible(true)
screen.SetBreadcrumbText("Movies", "Session")
categoryList = getCategoryListMovies()
categoryCount = categoryList.count()
seriesList = CreateObject("roList")
screen.SetupLists(categoryCount)
screen.setListNames(categoryList)
for i = 0 to categoryCount-1
tmpMoviesList = getMoviesByCategory(categoryList[i])
screen.SetContentList(i,tmpMoviesList)
seriesList.AddTail(tmpMoviesList)
end for
screen.show()
dlg.close()
while true
msg = wait(10, port)
if msg <> invalid and type(msg) = "roGridScreenEvent" then
if msg.isScreenClosed() then
exit while
else if msg.isListItemSelected() then
selection = seriesList.GetEntry(msg.GetIndex())[msg.GetData()]
if selection.Title = "Search"
searchMovies()
else if selection.Title = "Favorites"
FavoritesMovies()
else
showSpringboardScreenMovies(selection)
end if
end if
end if
end while
End Sub
Function getCategoryListMovies() as object
jsonAsString = CreateObject("roUrlTransfer")
jsonAsString.SetURL("http://"+initConfig()+"/category.php?t=movie")
json = ParseJson(jsonAsString.GetToString())
return json
End Function
Function getMoviesByCategory(category)
jsonAsString = CreateObject("roUrlTransfer")
jsonAsString.SetURL("http://"+initConfig()+"/movie.php?cat="+spaceEscape(category))
json = ParseJson(jsonAsString.GetToString())
return json.Videos
End Function
"TheEndless" wrote:
It's not entirely clear what you're asking. The GridScreen will open as soon as you call screen.show(). In your code, you're not calling screen.show() until after you've loaded the data. If you call screen.show() immediately after calling screen.setListNames(categoryList), it might do what you asking, but the speed of the show will still be dependent on how long your getCategoryListMovies() takes.
"hugetv" wrote:"TheEndless" wrote:
It's not entirely clear what you're asking. The GridScreen will open as soon as you call screen.show(). In your code, you're not calling screen.show() until after you've loaded the data. If you call screen.show() immediately after calling screen.setListNames(categoryList), it might do what you asking, but the speed of the show will still be dependent on how long your getCategoryListMovies() takes.
and that I can do to get Movies Category List () to make it more Thin and care less data to enter
Sub showMoviesScreen()
dlg = CreateObject("roOneLineDialog")
dlg.setTitle("Loading Collection")
dlg.showBusyAnimation()
dlg.show()
screen = CreateObject("roGridScreen")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.SetGridStyle("flat-portrait")
screen.SetDescriptionVisible(true)
screen.SetBreadcrumbText("Movies", "Session")
categoryList = getCategoryListMovies()
categoryCount = categoryList.count()
seriesList = CreateObject("roList")
screen.SetupLists(categoryCount)
screen.show()
screen.setListNames(categoryList)
for i = 0 to categoryCount-1
tmpMoviesList = getMoviesByCategory(categoryList[i])
screen.SetContentList(i,tmpMoviesList)
seriesList.AddTail(tmpMoviesList)
end for
dlg.close()
while true
msg = wait(10, port)
if msg <> invalid and type(msg) = "roGridScreenEvent" then
if msg.isScreenClosed() then
exit while
else if msg.isListItemSelected() then
selection = seriesList.GetEntry(msg.GetIndex())[msg.GetData()]
if selection.Title = "Search"
searchMovies()
else if selection.Title = "Favorites"
FavoritesMovies()
else
showSpringboardScreenMovies(selection)
end if
end if
end if
end while
End Sub
Function getCategoryListMovies() as object
jsonAsString = CreateObject("roUrlTransfer")
jsonAsString.SetURL("http://"+initConfig()+"/category.php?t=movie")
json = ParseJson(jsonAsString.GetToString())
return json
End Function
Function getMoviesByCategory(category)
jsonAsString = CreateObject("roUrlTransfer")
jsonAsString.SetURL("http://"+initConfig()+"/movie.php?cat="+spaceEscape(category))
json = ParseJson(jsonAsString.GetToString())
return json.Videos
End Function
selection = seriesList.GetEntry(msg.GetIndex())[msg.GetData()]
list = seriesList.GetEntry(msg.GetIndex())
if list <> invalid then
selection = list[msg.GetData()]
end if
"TheEndless" wrote:
That looks like you're getting a back index back from the event. You should add a null check...
Instead ofselection = seriesList.GetEntry(msg.GetIndex())[msg.GetData()]
Break it into multiple statements...list = seriesList.GetEntry(msg.GetIndex())
if list <> invalid then
selection = list[msg.GetData()]
end if