These files show how to use Mads Møller's sqlrest adapter to fetch the remove video metadata and cache it locally in a sqlite database. Replace the underscores in the file names with slashes to get their actual location in your project.
There were two issues with the adapter code that you posted in pastie: the columns were missing from the adapter definition, and you needed to specify a custom parser function in order to pull out the embedded videos[i].video objects. Also, the data that were posted to pastie were not valid JSON, so I had to fix that. The data used for this example can be found here: http://pastie.org/8580518.
The index.xml file above shows a basic list view that uses item templates and Alloy's data binding to create a list of video titles. The docs for ListView show more details about how to set up list item templates and bind model properties. In brief:
- Create a
Collectionelement that declares the collection to use for the list data. - Create an
ItemTemplatecontaining the UI controls that will display your data. Each UI control has to have a uniquebindIdattribute. - Create a
ListSectionwith andataCollectionelement that points to theCollectiondeclared earlier. EachListItemin the section maps model properties tobindIdvalues plus UI element properties from the item template. For example,<ListItem title:text="{video_title}"/>maps thevideo_titleproperty of the model to thetextproperty of the Label with a bindId of "title". You can bind model properties to many different UI elements in the item template.
Creating the collection with the <Collection/> tag in the view automatically adds your collection to the Alloy.Collections global object. The only thing to do now is tell the persistence adapter to get the data by calling Alloy.Collections.video.fetch(), then open the window. Alloy's data binding automatically populates the list view with one row per collection element.
You will probably want to add an itemId attribute to the ListItem containing each video's unique identifier as well as a click event handler to process clicks against the list.