/** Attempt to give each existing template a type, if possible */ public void setTemplateType() { for (int i = 0; i < listItemData.size(); i++) { TiListViewTemplate temp = listItemData.get(i).getTemplate(); TiListView listView = getListView(); if (temp.getType() == -1) { temp.setType(listView.getItemType()); } } }
private TiListViewTemplate processDefaultTemplate(KrollDict data, int index) { if (builtInTemplate == null) { // Create template and generate default properties builtInTemplate = new TiDefaultListViewTemplate(UIModule.LIST_ITEM_TEMPLATE_DEFAULT, null, getActivity()); // Each template is treated as an item type, so we can reuse views efficiently. // Section templates are given a type in TiListView.processSections(). Here we // give default template a type if possible. TiListView listView = getListView(); if (listView != null) { builtInTemplate.setType(TiListView.BUILT_IN_TEMPLATE_ITEM_TYPE); builtInTemplate.setRootParent(listView.getProxy()); } } return builtInTemplate; }
private TiListViewTemplate processTemplate(KrollDict itemData, int index) { TiListView listView = getListView(); String defaultTemplateBinding = null; if (listView != null) { defaultTemplateBinding = listView.getDefaultTemplateBinding(); } // if template is specified in data, we look it up and if one exists, we use it. // Otherwise we check if a default template is specified in ListView. If not, we use // builtInTemplate. String binding = TiConvert.toString(itemData.get(TiC.PROPERTY_TEMPLATE)); if (binding != null) { // check if template is default if (binding.equals(UIModule.LIST_ITEM_TEMPLATE_DEFAULT)) { return processDefaultTemplate(itemData, index); } TiListViewTemplate template = listView.getTemplateByBinding(binding); // if template is successfully retrieved, bind it to the index. This is b/c // each row can have a different template. if (template == null) { Log.e(TAG, "Template undefined"); } return template; } else { // if a valid default template is specify, use that one if (defaultTemplateBinding != null && !defaultTemplateBinding.equals(UIModule.LIST_ITEM_TEMPLATE_DEFAULT)) { TiListViewTemplate defTemplate = listView.getTemplateByBinding(defaultTemplateBinding); if (defTemplate != null) { return defTemplate; } } return processDefaultTemplate(itemData, index); } }