Step 3: Set Up the Categories Recipe
In this step, you will start configuring the category recipe for your feed. Categories group your media into different collections or channels. Categories are a way of organizing your media so that all your video isn't in one long list. For a general overview of recipe configuration, see Recipe Configuration Overview.
Configure the Categories Recipe
-
If you didn't already duplicate and rename the LightCast recipe files, see Customize the Recipe Files in the previous topic.
Note: In the previous topic, you customized the "LightCast" name in the files to something unique, such as "AcmeMedia". In these instructions, <project name> represents this customization. -
Open the <project name>CategoriesRecipe.json file (located in app > assets > recipes).
The default categories recipe configuration looks like this:
{ "cooker": "DynamicParser", "format": "json", "model": "com.amazon.android.model.content.ContentContainer", "translator": "ContentContainerTranslator", "modelType": "array", "query": "$..categories[*]", "queryResultType": "[]$", "matchList": [ "StringKey@mName" ], "keyDataType": "StringKey@keyDataPath" }
-
Configure the file's values as explained in the following table.
Note: Because thequery
andmatchList
are more complex, their configurations are explained in the topics that follow — Categories Recipe: Query Parameters and Categories Recipe: Matchlist Parameters.Key Description cooker
Defines which utility will take the parameters defined in the recipe and run the logic. In other words, the cooker "cooks" the recipe. Leave it at the default value:
DynamicParser
.format
Specifies the data format for the incoming data feed. Options are
json
orxml
.model
Specifies the content model for the data. The content model provides the structure for your content and maps it into the Fire App Builder UI. Leave it at the default:
com.amazon.android.model.content.ContentContainer
.translator
Specifies whether translation or reflection is used when converting your feed's objects to the Fire App Builder content model. Translation is faster and recommended. To use translation, simply leave the value at the default:
ContentContainerTranslator
. If you want to use reflection instead, remove thetranslator
parameter altogether from the recipe.modelType
Specifies whether the feed is an array or a single object. Available options are
array
orsingle
. Almost all feeds arearray
. For example, if your JSON feed is enclosed within square brackets, or your XML feed has nested angle brackets, choosearray
. If your feed is structured as a single object, choosesingle
.query
A query used to return categories from your media feed. The syntax of the query depends on the structure of your feed. You will need to construct the right query to get your categories. For JSON feeds, use Jayway JsonPath syntax for the query syntax. For XML feeds, use XPath expressions for the query syntax. Leave this field's value as is for now. You will configure it in the next step: Categories Recipe: query Parameter.
queryResultType
If the result from
query
parameter returns a list of strings, include thisqueryResultType
parameter and set it equal to[]$
. If the query's result is an object (a map), omit this parameter. (Fire App Builder needs to know the result type because it will needs to push an object into a Java hashmap.) Leave this field's value as is for now. You will configure it in the next step: Categories Recipe: Query Parameters.matchList
The query that you defined in the
query
parameter returns a result. This result needs to be mapped from your feed's names to the names Fire App Builder uses in its content model. ThematchList
parameter maps the results from the query to the name for media categories in Fire App Builder. Leave this field's value as is for now. You will configure it in an upcoming step: Categories Recipe: Matchlist Parameters.keyDataType
The media objects that are related to the category. It's essential to identify which media should be grouped into which category. Similar to
matchList
, you target the items on the left followed by@
and thenkeyDataPath
to map and identify these media objects to the category. For example:StringKey@keyDataPath
. Leave this field's value as is for now. You will configure it an upcoming step: Categories Recipe: matchlist Parameter.
Feeds without Categories
If your feed lacks categories but you have separate feeds for each category, you can hard-code the category names when you configure Navigator.json. This will group all the videos in a particular feed with a particular category. More detail for this approach is provided in the "Hardcoding Your Categories."
Next Steps
Now that you've configured the basic properties in the category recipe, let's dig into the query parameters. Continue to the next step: Categories Recipe: query Parameter.
Last updated: Apr 06, 2017