Java Code Examples for org.appcelerator.titanium.TiC#PROPERTY_PROPERTIES

The following examples show how to use org.appcelerator.titanium.TiC#PROPERTY_PROPERTIES . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CollectionViewTemplate.java    From TiCollectionView with MIT License 6 votes vote down vote up
public CollectionViewTemplate(String id, KrollDict properties) {
	//Init our binding hashmaps
	dataItems = new HashMap<String, DataItem>();

	//Set item id. Item binding is always "properties"
	itemID = TiC.PROPERTY_PROPERTIES;
	//Init vars.
	templateID = id;
	templateType = -1;
	if (properties != null) {
		this.properties = properties;
		processProperties(this.properties);
	} else {
		this.properties = new KrollDict();
	}

}
 
Example 2
Source File: CollectionViewTemplate.java    From TiCollectionView with MIT License 5 votes vote down vote up
private DataItem bindProxiesAndProperties(KrollDict properties, boolean isRootTemplate, DataItem parent) {
	Object proxy = null;
	String id = null;
	Object props = null;
	DataItem item = null;
	if (properties.containsKey(TiC.PROPERTY_TI_PROXY)) {
		proxy = properties.get(TiC.PROPERTY_TI_PROXY);
	}

	//Get/generate random bind id
	if (isRootTemplate) {
		id = itemID;	
	} else if (properties.containsKey(TiC.PROPERTY_BIND_ID)) {
		id = TiConvert.toString(properties, TiC.PROPERTY_BIND_ID);
	} else {
		id = GENERATED_BINDING + Math.random();
	}
	

	if (proxy instanceof TiViewProxy) {
		TiViewProxy viewProxy = (TiViewProxy) proxy;
		if (isRootTemplate) {
			rootItem = item = new DataItem(viewProxy, TiC.PROPERTY_PROPERTIES, null);
		} else {
			item = new DataItem(viewProxy, id, parent);
			parent.addChild(item);
		}
		dataItems.put(id, item);
	}

	if (properties.containsKey(TiC.PROPERTY_PROPERTIES)) {
		props = properties.get(TiC.PROPERTY_PROPERTIES);
	}
	
	if (props instanceof HashMap) {
		item.setDefaultProperties(new KrollDict((HashMap)props));
	}

	return item;
}
 
Example 3
Source File: DefaultCollectionViewTemplate.java    From TiCollectionView with MIT License 4 votes vote down vote up
public void generateDefaultProps(Activity activity) {
	
	//Generate root item data proxy
	CollectionItemProxy proxy = new CollectionItemProxy();
	proxy.setActivity(activity);
	rootItem = new DataItem(proxy, TiC.PROPERTY_PROPERTIES, null);
	dataItems.put(itemID, rootItem);

	//Init default properties for our proxies
	KrollDict defaultLabelProperties = new KrollDict();
	KrollDict defaultImageProperties = new KrollDict();

	//Generate label proxy
	LabelProxy labelProxy = new LabelProxy();
	labelProxy.getProperties().put(TiC.PROPERTY_TOUCH_ENABLED, false);
	labelProxy.setActivity(activity);
	//Generate properties
	defaultLabelProperties.put(TiC.PROPERTY_LEFT, "2dp");
	defaultLabelProperties.put(TiC.PROPERTY_WIDTH, "55%");
	defaultLabelProperties.put(TiC.PROPERTY_TEXT, "label");
	//bind the proxy and default propertiess
	DataItem labelItem = new DataItem(labelProxy, TiC.PROPERTY_TITLE, rootItem);
	dataItems.put(TiC.PROPERTY_TITLE, labelItem);
	//set default properties
	labelItem.setDefaultProperties(defaultLabelProperties);
	//add child
	rootItem.addChild(labelItem);
	
	//Generate image proxy
	ImageViewProxy imageProxy = new ImageViewProxy();
	imageProxy.getProperties().put(TiC.PROPERTY_TOUCH_ENABLED, false);
	imageProxy.setActivity(activity);
	//Generate properties
	defaultImageProperties.put(TiC.PROPERTY_RIGHT, "25dp");
	defaultImageProperties.put(TiC.PROPERTY_WIDTH, "15%");
	//bind the proxy and default properties
	DataItem imageItem = new DataItem (imageProxy, TiC.PROPERTY_IMAGE, rootItem);
	dataItems.put(TiC.PROPERTY_IMAGE, imageItem);
	//set default properties
	imageItem.setDefaultProperties(defaultImageProperties);
	//add child
	rootItem.addChild(imageItem);
	

}