Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
xoceunder
Roku Guru

help with being able to load individual category

help with being able to load individual category I am using GridScreen and I want to load 12 categories and load the first 2 to make the entry faster and then when selecting the category I can load the content of it and show it can you help me with this I am trying to do a video game project

0 Kudos
4 REPLIES 4
xoceunder
Roku Guru

Re: help with being able to load individual category

 

how can I select category can load the content to insert the corresponding category

use and code

 

'handler of focused item in RowList
Sub OnItemFocused()
	itemFocused=m.top.itemFocused
    focusedIndex = m.rowList.rowItemFocused ' get position of focused item
	row = m.rowList.content.GetChild(focusedIndex[0]) ' get all items of row
	'When an item gains the key focus, set to a 2-element array,
	'where element 0 contains the index of the focused row,
	'and element 1 contains the index of the focused item in that row.
	If itemFocused.Count()=2
		focusedContent=m.top.content.getChild(itemFocused[0]).getChild(itemFocused[1])
		If focusedContent<>invalid
			m.top.focusedContent=focusedContent
			m.description.content=focusedContent
			m.background.uri=focusedContent.hdBackgroundImageUrl
		End If
	End If
End Sub
0 Kudos
xoceunder
Roku Guru

Re: help with being able to load individual category

Here I leave my project to see if someone can help to make the independent categories load so I can quickly enter the section and thanks in advance

https://github.com/xoceunder/RokuDev

0 Kudos
xoceunder
Roku Guru

Re: help with being able to load individual category

 

' ********** Copyright 2016 Roku Corp.  All Rights Reserved. **********
'inits grid screen
'creates all children
'sets all observers

Function Init()
	Print"[GridScreen] Init"
	
	m.rowList=m.top.findNode("RowList")
	m.description=m.top.findNode("Description")
	m.background=m.top.findNode("Background")
	m.background.setFocus(true)
	m.top.observeField("visible","onVisibleChange")
	m.top.observeField("focusedChild","OnFocusedChildChange")
End Function

'handler of focused item in RowList
Sub OnItemFocused()

	itemFocused=m.top.itemFocused
    focusedIndex = m.rowList.rowItemFocused ' get position of focused item
    row = m.rowList.content.GetChild(focusedIndex[0]) ' get all items of row
    item = row.GetChild(focusedIndex[1]) ' get focused item
	
	If itemFocused.Count()=2
		focusedContent=m.top.content.getChild(itemFocused[0]).getChild(itemFocused[1])
		print focusedContent
		If item<>invalid
			m.top.focusedContent=item
			m.description.content=item
			m.background.uri=item.hdBackgroundImageUrl
		End If
	End If

    If  row.getChildCount()=0
        print "children empty: " row.id
		numRows = 9
		for i = 0 To numRows - 1
            rowNew = CreateObject("rosgnode", "ContentNode")
			rowNew.title = "MOVIE ROW " + i.toStr()
			rowNew.HDPosterURL="https://image.tmdb.org/t/p/w300/jl8rZYy7JmbWlBlvDCfwvDmGO0g.jpg"
		    m.rowList.content.insertChildren(rowNew, focusedIndex[0])
		end for
	End If
End Sub

'set proper focus to RowList in case if return from Details Screen
Sub onVisibleChange()
	If m.top.visible=TRUE
		m.rowList.setFocus(TRUE)
	End If
End Sub

'set proper focus to RowList in case if return from Details Screen
Sub OnFocusedChildChange()
	If m.top.isInFocusChain() And Not m.rowList.hasFocus()
		m.rowList.setFocus(TRUE)
	End If
End Sub

 

 

Trying to be able to insert Content Node to a tree that is without content, I don't know if I'm right or if I'm doing something wrong

0 Kudos
xoceunder
Roku Guru

Re: help with being able to load individual category

BRIGHTSCRIPT: ERROR: roUrlTransfer: creating MAIN|TASK-only component failed on RENDER thread: pkg:/components/GridScreen/GridScreen.brs(65)

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Suspending threads...
Thread selected: 1* ...nts/GridScreen/GridScreen.brs(66) readInternet.setU rl(m.global.serverURL+"/api.php?cmd=content

Current Function:
064: Function getMoviesItem(parent As Object, category As String ,tipo As Strin g)
065: readInternet=createObject("roUrlTransfer")
066:* readInternet.setUrl(m.global.serverURL+"/api.php?cmd=content&type=movies &category=566")
067: source=readInternet.GetToString()
068: responseJSON = ParseJSON(source)
069: if responseJSON <> invalid then
070: For Each itemAA In responseJSON.content
Source Digest(s):
pkg: dev 1.0.0 59d74b62e604c12b1ee3f964d2a06aeb XOE Beta
roku_ads_lib: 58484 3.1.32 65f6a6a4a52db3873fa28080237f47e4a31b5c16a36bf7d67e7e4 2ac39f1ff36 Roku Ads Library

'Dot' Operator attempted with invalid BrightScript Component or interface refere nce. (runtime error &hec) in pkg:/components/GridScreen/GridScreen.brs(66)
Backtrace:
#1 Function getmoviesitem(parent As Object, category As String, tipo As String) As Dynamic
file/line: pkg:/components/GridScreen/GridScreen.brs(66)
#0 Function onitemfocused() As Void
file/line: pkg:/components/GridScreen/GridScreen.brs(39)
Local Variables:
parent roSGNode:ContentNode refcnt=2
category roString (2.1 was String) refcnt=1 val:"0"
tipo String (VT_STR_CONST) val:"movies"
global Interface:ifGlobal
m roAssociativeArray refcnt=3 count:5
readinternet Invalid
source <uninitialized>
responsejson <uninitialized>
itemaa <uninitialized>
itemnew <uninitialized>
Threads:

 

 

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.