org.appcelerator.titanium.TiC Java Examples
The following examples show how to use
org.appcelerator.titanium.TiC.
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: CollectionViewProxy.java From TiCollectionView with MIT License | 6 votes |
@Kroll.method public void scrollToItem(int sectionIndex, int itemIndex, @SuppressWarnings("rawtypes") @Kroll.argument(optional=true)HashMap options) { boolean animated = true; if ( (options != null) && (options instanceof HashMap<?, ?>) ) { @SuppressWarnings("unchecked") KrollDict animationargs = new KrollDict(options); if (animationargs.containsKeyAndNotNull(TiC.PROPERTY_ANIMATED)) { animated = TiConvert.toBoolean(animationargs.get(TiC.PROPERTY_ANIMATED), true); } } if (TiApplication.isUIThread()) { handleScrollToItem(sectionIndex, itemIndex, animated); } else { KrollDict d = new KrollDict(); d.put("itemIndex", itemIndex); d.put("sectionIndex", sectionIndex); d.put(TiC.PROPERTY_ANIMATED, Boolean.valueOf(animated)); TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SCROLL_TO_ITEM), d); } }
Example #2
Source File: CollectionViewProxy.java From TiCollectionView with MIT License | 6 votes |
@Kroll.setProperty @Kroll.method public void setSections(Object sections) { if (!(sections instanceof Object[])) { Log.e(TAG, "Invalid argument type to setSection(), needs to be an array", Log.DEBUG_MODE); return; } //Update java and javascript property setProperty(TiC.PROPERTY_SECTIONS, sections); Object[] sectionsArray = (Object[]) sections; TiUIView listView = peekView(); //Preload sections if listView is not opened. if (listView == null) { preload = true; clearPreloadSections(); addPreloadSections(sectionsArray, -1, true); } else { if (TiApplication.isUIThread()) { ((CollectionView)listView).processSectionsAndNotify(sectionsArray); } else { TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_SECTIONS), sectionsArray); } } }
Example #3
Source File: CollectionItem.java From TiCollectionView with MIT License | 6 votes |
protected void handleFireItemClick (KrollDict data) { TiViewProxy listViewProxy = ((CollectionItemProxy)proxy).getListProxy(); if (listViewProxy != null) { TiUIView listView = listViewProxy.peekView(); if (listView != null) { KrollDict d = listView.getAdditionalEventData(); if (d == null) { listView.setAdditionalEventData(new KrollDict((HashMap) additionalEventData)); } else { d.clear(); d.putAll(additionalEventData); } listView.fireEvent(TiC.EVENT_ITEM_CLICK, data); } } }
Example #4
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 6 votes |
@Kroll.method public void replaceItemsAt(int index, int count, Object data) { if (!isIndexValid(index)) { return; } if (TiApplication.isUIThread()) { handleReplaceItemsAt(index, count, data); } else { KrollDict d = new KrollDict(); d.put(TiC.EVENT_PROPERTY_INDEX, index); d.put(TiC.PROPERTY_COUNT, count); d.put(TiC.PROPERTY_DATA, data); TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_REPLACE_ITEMS_AT), d); } }
Example #5
Source File: RealSwitch.java From RealSwitch with MIT License | 6 votes |
@Override public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy) { CompoundButton cb = (CompoundButton) getNativeView(); if (key.equals(TiC.PROPERTY_TITLE_OFF)) { ((Switch) cb).setTextOff((String) newValue); } else if (key.equals(TiC.PROPERTY_TITLE_ON)) { ((Switch) cb).setTextOff((String) newValue); } else if (key.equals(TiC.PROPERTY_VALUE)) { cb.setChecked(TiConvert.toBoolean(newValue)); } else if (key.equals(TiC.PROPERTY_COLOR)) { cb.setTextColor(TiConvert.toColor(TiConvert.toString(newValue))); } else if (key.equals(TiC.PROPERTY_FONT)) { TiUIHelper.styleText(cb, (KrollDict) newValue); } else if (key.equals(TiC.PROPERTY_TEXT_ALIGN)) { TiUIHelper.setAlignment(cb, TiConvert.toString(newValue), null); cb.requestLayout(); } else if (key.equals(TiC.PROPERTY_VERTICAL_ALIGN)) { TiUIHelper.setAlignment(cb, null, TiConvert.toString(newValue)); cb.requestLayout(); } else { super.propertyChanged(key, oldValue, newValue, proxy); } }
Example #6
Source File: CollectionViewTemplate.java From TiCollectionView with MIT License | 6 votes |
private void processChildProperties(Object childProperties, DataItem parent) { if (childProperties instanceof Object[]) { Object[] propertiesArray = (Object[])childProperties; for (int i = 0; i < propertiesArray.length; i++) { HashMap<String, Object> properties = (HashMap<String, Object>) propertiesArray[i]; //bind proxies and default properties DataItem item = bindProxiesAndProperties(new KrollDict(properties), false, parent); //Recursively calls for all childTemplates if (properties.containsKey(TiC.PROPERTY_CHILD_TEMPLATES)) { if(item == null) { Log.e(TAG, "Unable to generate valid data from child view", Log.DEBUG_MODE); } processChildProperties(properties.get(TiC.PROPERTY_CHILD_TEMPLATES), item); } } } }
Example #7
Source File: CollectionViewTemplate.java From TiCollectionView with MIT License | 6 votes |
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 #8
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 6 votes |
public CollectionItemData (KrollDict properties, CollectionViewTemplate template) { this.properties = properties; this.template = template; //set searchableText if (properties.containsKey(TiC.PROPERTY_PROPERTIES)) { Object props = properties.get(TiC.PROPERTY_PROPERTIES); if (props instanceof HashMap) { HashMap<String, Object> propsHash = (HashMap<String, Object>) props; Object searchText = propsHash.get(TiC.PROPERTY_SEARCHABLE_TEXT); if (propsHash.containsKey(TiC.PROPERTY_SEARCHABLE_TEXT) && searchText != null) { searchableText = TiConvert.toString(searchText); } } } }
Example #9
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 5 votes |
@Kroll.method public void insertItemsAt(int index, Object data) { if (!isIndexValid(index)) { return; } if (TiApplication.isUIThread()) { handleInsertItemsAt(index, data); } else { KrollDict d = new KrollDict(); d.put(TiC.PROPERTY_DATA, data); d.put(TiC.EVENT_PROPERTY_INDEX, index); TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_INSERT_ITEMS_AT), d); } }
Example #10
Source File: ExampleProxy.java From TiCollectionView with MIT License | 5 votes |
public ExampleView(TiViewProxy proxy) { super(proxy); LayoutArrangement arrangement = LayoutArrangement.DEFAULT; if (proxy.hasProperty(TiC.PROPERTY_LAYOUT)) { String layoutProperty = TiConvert.toString(proxy.getProperty(TiC.PROPERTY_LAYOUT)); if (layoutProperty.equals(TiC.LAYOUT_HORIZONTAL)) { arrangement = LayoutArrangement.HORIZONTAL; } else if (layoutProperty.equals(TiC.LAYOUT_VERTICAL)) { arrangement = LayoutArrangement.VERTICAL; } } setNativeView(new TiCompositeLayout(proxy.getActivity(), arrangement)); }
Example #11
Source File: CollectionItem.java From TiCollectionView with MIT License | 5 votes |
public void processProperties(KrollDict d) { if (d.containsKey(TiC.PROPERTY_ACCESSORY_TYPE)) { int accessory = TiConvert.toInt(d.get(TiC.PROPERTY_ACCESSORY_TYPE), -1); handleAccessory(accessory); } if (d.containsKey(TiC.PROPERTY_SELECTED_BACKGROUND_COLOR)) { d.put(TiC.PROPERTY_BACKGROUND_SELECTED_COLOR, d.get(TiC.PROPERTY_SELECTED_BACKGROUND_COLOR)); } if (d.containsKey(TiC.PROPERTY_SELECTED_BACKGROUND_IMAGE)) { d.put(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE, d.get(TiC.PROPERTY_SELECTED_BACKGROUND_IMAGE)); } super.processProperties(d); }
Example #12
Source File: DefaultCollectionViewTemplate.java From TiCollectionView with MIT License | 5 votes |
private void parseDefaultData(KrollDict data) { //for built-in template, we only process 'properties' key Iterator<String> bindings = data.keySet().iterator(); while (bindings.hasNext()) { String binding = bindings.next(); if (!binding.equals(TiC.PROPERTY_PROPERTIES)) { Log.e(TAG, "Please only use 'properties' key for built-in template", Log.DEBUG_MODE); bindings.remove(); } } KrollDict properties = data.getKrollDict(TiC.PROPERTY_PROPERTIES); KrollDict clone_properties = new KrollDict((HashMap)properties); if (clone_properties.containsKey(TiC.PROPERTY_TITLE)) { KrollDict text = new KrollDict(); text.put(TiC.PROPERTY_TEXT, TiConvert.toString(clone_properties, TiC.PROPERTY_TITLE)); data.put(TiC.PROPERTY_TITLE, text); if (clone_properties.containsKey(TiC.PROPERTY_FONT)) { text.put(TiC.PROPERTY_FONT, clone_properties.getKrollDict(TiC.PROPERTY_FONT).clone()); clone_properties.remove(TiC.PROPERTY_FONT); } if (clone_properties.containsKey(TiC.PROPERTY_COLOR)) { text.put(TiC.PROPERTY_COLOR, clone_properties.get(TiC.PROPERTY_COLOR)); clone_properties.remove(TiC.PROPERTY_COLOR); } clone_properties.remove(TiC.PROPERTY_TITLE); } if (clone_properties.containsKey(TiC.PROPERTY_IMAGE)) { KrollDict image = new KrollDict(); image.put(TiC.PROPERTY_IMAGE, TiConvert.toString(clone_properties, TiC.PROPERTY_IMAGE)); data.put(TiC.PROPERTY_IMAGE, image); clone_properties.remove(TiC.PROPERTY_IMAGE); } data.put(TiC.PROPERTY_PROPERTIES, clone_properties); }
Example #13
Source File: DefaultCollectionViewTemplate.java From TiCollectionView with MIT License | 5 votes |
public void updateOrMergeWithDefaultProperties(KrollDict data, boolean update) { if (!data.containsKey(TiC.PROPERTY_PROPERTIES)) { Log.e(TAG, "Please use 'properties' binding for builtInTemplate"); if (!update) { //apply default behavior data.clear(); } return; } parseDefaultData(data); super.updateOrMergeWithDefaultProperties(data, update); }
Example #14
Source File: CollectionViewProxy.java From TiCollectionView with MIT License | 5 votes |
public void handleCreationDict(KrollDict options) { super.handleCreationDict(options); //Adding sections to preload sections, so we can handle appendSections/insertSection //accordingly if user call these before TiListView is instantiated. if (options.containsKey(TiC.PROPERTY_SECTIONS)) { Object obj = options.get(TiC.PROPERTY_SECTIONS); if (obj instanceof Object[]) { addPreloadSections((Object[]) obj, -1, true); } } }
Example #15
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 5 votes |
@Kroll.method public void deleteItemsAt(int index, int count) { if (!isIndexValid(index)) { return; } if (TiApplication.isUIThread()) { handleDeleteItemsAt(index, count); } else { KrollDict d = new KrollDict(); d.put(TiC.EVENT_PROPERTY_INDEX, index); d.put(TiC.PROPERTY_COUNT, count); TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_DELETE_ITEMS_AT), d); } }
Example #16
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 5 votes |
@Kroll.method public void updateItemAt(int index, Object data) { if (!isIndexValid(index) || !(data instanceof HashMap)) { return; } if (TiApplication.isUIThread()) { handleUpdateItemAt(index, new Object[]{data}); } else { KrollDict d = new KrollDict(); d.put(TiC.EVENT_PROPERTY_INDEX, index); d.put(TiC.PROPERTY_DATA, new Object[]{data}); TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_UPDATE_ITEM_AT), d); } }
Example #17
Source File: CollectionSectionProxy.java From TiCollectionView with MIT License | 5 votes |
private CollectionViewTemplate processTemplate(KrollDict itemData, int index) { CollectionView 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); } CollectionViewTemplate 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)) { CollectionViewTemplate defTemplate = listView.getTemplateByBinding(defaultTemplateBinding); if (defTemplate != null) { return defTemplate; } } return processDefaultTemplate(itemData, index); } }
Example #18
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 5 votes |
/** * Helper function to process font objects used for title and subtitle * * @param Context - TiApplication context * @param Object - the properties as hashmap * @param Text - SpannableStringBuilder that should get the properties applied * @param TypefaceSpan - font reference (for title or subtitle) */ private SpannableStringBuilder applyFontProperties(TiApplication appContext, HashMap<String, String> d, SpannableStringBuilder ssb, TypefaceSpan font){ if (d.containsKey(TiC.PROPERTY_FONTFAMILY)){ String fontFamily = d.get(TiC.PROPERTY_FONTFAMILY).replaceAll("\\.(ttf|otf|fnt)$", ""); font = new TypefaceSpan(appContext, fontFamily); ssb.setSpan(font, 0, ssb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); } if (d.containsKey(TiC.PROPERTY_FONTSIZE)){ Object value = d.get(TiC.PROPERTY_FONTSIZE); boolean dip = false; int fontSize; if (value instanceof String){ // is there a better way to convert Strings ("16px", "22sp" etc.) to dip? fontSize = (int) TiUIHelper.getRawSize( TiUIHelper.getSizeUnits((String) value), TiUIHelper.getSize((String) value), appContext ); }else { fontSize = (Integer) value; dip = true; } ssb.setSpan(new AbsoluteSizeSpan(fontSize, dip), 0, ssb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); } if (d.containsKey(TiC.PROPERTY_FONTWEIGHT)){ String fontWeight = d.get(TiC.PROPERTY_FONTWEIGHT); ssb.setSpan(new StyleSpan(TiUIHelper.toTypefaceStyle(fontWeight, null)), 0, ssb.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); } return ssb; }
Example #19
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 5 votes |
/** * You can set just the title with setTitle("title") * or title, color and font at once with: * setTitle({ * text: "title", * color: "#f00", * font: "MyFont.otf" * }) * * @param obj */ @Kroll.method @Kroll.setProperty public void setTitle(Object obj) { String title; if (obj instanceof String){ title = (String) obj; }else if(obj instanceof HashMap){ @SuppressWarnings("unchecked") HashMap<String, String> d = (HashMap<String, String>) obj; title = (String) d.get(TiC.PROPERTY_TEXT); if (d.containsKey(TiC.PROPERTY_COLOR)){ setTitleColor((String) d.get(TiC.PROPERTY_COLOR)); } if (d.containsKey(TiC.PROPERTY_FONT)){ setTitleFont(d.get(TiC.PROPERTY_FONT)); } }else{ return; } Message message = getMainHandler().obtainMessage(MSG_TITLE, title); message.sendToTarget(); }
Example #20
Source File: ActionbarextrasModule.java From actionbarextras with MIT License | 5 votes |
/** * You can set just the subtitle with setSubtitle("subtitle") * or subtitle, color and font at once with: * setSubtitle({ * text: "subtitle", * color: "#f00", * font: "MyFont.otf" * }) * * @param obj */ @Kroll.method @Kroll.setProperty public void setSubtitle(Object obj) { String subtitle; if (obj instanceof String){ subtitle = (String) obj; }else if(obj instanceof HashMap){ @SuppressWarnings("unchecked") HashMap<String, String> d = (HashMap<String, String>) obj; subtitle = (String) d.get(TiC.PROPERTY_TEXT); if (d.containsKey(TiC.PROPERTY_COLOR)){ setSubtitleColor((String) d.get(TiC.PROPERTY_COLOR)); } if (d.containsKey(TiC.PROPERTY_FONT)){ setSubtitleFont(d.get(TiC.PROPERTY_FONT)); } }else if(obj == null){ subtitle = null; }else{ return; } Message message = getMainHandler().obtainMessage(MSG_SUBTITLE, subtitle); message.sendToTarget(); }
Example #21
Source File: ExampleProxy.java From NovarumBluetooth with MIT License | 5 votes |
public ExampleView(TiViewProxy proxy) { super(proxy); LayoutArrangement arrangement = LayoutArrangement.DEFAULT; if (proxy.hasProperty(TiC.PROPERTY_LAYOUT)) { String layoutProperty = TiConvert.toString(proxy.getProperty(TiC.PROPERTY_LAYOUT)); if (layoutProperty.equals(TiC.LAYOUT_HORIZONTAL)) { arrangement = LayoutArrangement.HORIZONTAL; } else if (layoutProperty.equals(TiC.LAYOUT_VERTICAL)) { arrangement = LayoutArrangement.VERTICAL; } } setNativeView(new TiCompositeLayout(proxy.getActivity(), arrangement)); }
Example #22
Source File: RealSwitch.java From RealSwitch with MIT License | 5 votes |
@Override public void onCheckedChanged(CompoundButton btn, boolean value) { KrollDict data = new KrollDict(); proxy.setProperty(TiC.PROPERTY_VALUE, value); // if user triggered change, we fire it. if (oldValue != value) { data.put(TiC.PROPERTY_VALUE, value); fireEvent(TiC.EVENT_CHANGE, data); oldValue = value; } }
Example #23
Source File: GalleryResultHandler.java From titanium-imagepicker with Apache License 2.0 | 5 votes |
@Override public void onResult(Activity activity, int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_CANCELED){ flushResponse(TiC.PROPERTY_CANCEL, true, TiC.PROPERTY_SUCCESS, false, TiC.EVENT_PROPERTY_MESSAGE, "Result Cancelled"); } else if (Defaults.REQUEST_CODE == requestCode && resultCode == Activity.RESULT_OK) { if (null != data && data.hasExtra(TiC.PROPERTY_SUCCESS) && data.hasExtra(Defaults.Params.IMAGES)) { ArrayList<CharSequence> imagePaths = data.getCharSequenceArrayListExtra(Defaults.Params.IMAGES); flushResponse(TiC.PROPERTY_CANCEL, false, TiC.PROPERTY_SUCCESS, true, Defaults.Params.IMAGES, imagePaths.toArray()); } } }
Example #24
Source File: ImagePickerActivity.java From titanium-imagepicker with Apache License 2.0 | 5 votes |
private void processImages(String path) { ArrayList<CharSequence> imagePaths = new ArrayList<CharSequence>(); if (isMultipleSelection) { if (0 == totalSelectedImages) { Toast.makeText(getApplicationContext(), "No pictures selected.", Toast.LENGTH_SHORT).show(); return; } final int totalCount = adapter.size(); int totalImages = totalSelectedImages; int i = 0; while((totalImages > 0) && (i < totalCount)) { if (adapter.get(i).selectionState) { imagePaths.add("file://" + adapter.get(i).imagePath); --totalImages; } ++i; } } else { imagePaths.add(path); } Intent intent = new Intent(); intent.putExtra(Defaults.Params.IMAGES, imagePaths); intent.putExtra(TiC.PROPERTY_SUCCESS, true); setResult(RESULT_OK, intent); finish(); }
Example #25
Source File: GalleryResultHandler.java From titanium-imagepicker with Apache License 2.0 | 5 votes |
@Override public void onResult(Activity activity, int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_CANCELED){ flushResponse(TiC.PROPERTY_CANCEL, true, TiC.PROPERTY_SUCCESS, false, TiC.EVENT_PROPERTY_MESSAGE, "Result Cancelled"); } else if (Defaults.REQUEST_CODE == requestCode && resultCode == Activity.RESULT_OK) { if (null != data && data.hasExtra(TiC.PROPERTY_SUCCESS) && data.hasExtra(Defaults.Params.IMAGES)) { ArrayList<CharSequence> imagePaths = data.getCharSequenceArrayListExtra(Defaults.Params.IMAGES); flushResponse(TiC.PROPERTY_CANCEL, false, TiC.PROPERTY_SUCCESS, true, Defaults.Params.IMAGES, imagePaths.toArray()); } } }
Example #26
Source File: ImagePickerActivity.java From titanium-imagepicker with Apache License 2.0 | 5 votes |
private void processImages(String path) { ArrayList<CharSequence> imagePaths = new ArrayList<CharSequence>(); if (isMultipleSelection) { if (0 == totalSelectedImages) { Toast.makeText(getApplicationContext(), "No pictures selected.", Toast.LENGTH_SHORT).show(); return; } final int totalCount = adapter.size(); int totalImages = totalSelectedImages; int i = 0; while((totalImages > 0) && (i < totalCount)) { if (adapter.get(i).selectionState) { imagePaths.add("file://" + adapter.get(i).imagePath); --totalImages; } ++i; } } else { imagePaths.add(path); } Intent intent = new Intent(); intent.putExtra(Defaults.Params.IMAGES, imagePaths); intent.putExtra(TiC.PROPERTY_SUCCESS, true); setResult(RESULT_OK, intent); finish(); }
Example #27
Source File: RealSwitch.java From RealSwitch with MIT License | 5 votes |
@Override public void processProperties(KrollDict d) { super.processProperties(d); // Create Real Switch CompoundButton button = new Switch(proxy.getActivity()) { @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); TiUIHelper.firePostLayoutEvent(proxy); } }; setNativeView(button); updateButton(button, proxy.getProperties()); button.setOnCheckedChangeListener(this); if (d.containsKey(TiC.PROPERTY_VALUE)) { oldValue = TiConvert.toBoolean(d, TiC.PROPERTY_VALUE); } View nativeView = getNativeView(); if (nativeView != null) { updateButton((CompoundButton) nativeView, d); } }
Example #28
Source File: RealSwitch.java From RealSwitch with MIT License | 5 votes |
protected void updateButton(CompoundButton cb, KrollDict d) { if (d.containsKey(TiC.PROPERTY_TITLE_OFF)) { ((Switch) cb).setTextOff(TiConvert.toString(d, TiC.PROPERTY_TITLE_OFF)); } if (d.containsKey(TiC.PROPERTY_TITLE_ON)) { ((Switch) cb).setTextOn(TiConvert.toString(d, TiC.PROPERTY_TITLE_ON)); } if (d.containsKey(TiC.PROPERTY_VALUE)) { cb.setChecked(TiConvert.toBoolean(d, TiC.PROPERTY_VALUE)); } if (d.containsKey(TiC.PROPERTY_COLOR)) { cb.setTextColor(TiConvert.toColor(d, TiC.PROPERTY_COLOR)); } if (d.containsKey(TiC.PROPERTY_FONT)) { TiUIHelper.styleText(cb, d.getKrollDict(TiC.PROPERTY_FONT)); } if (d.containsKey(TiC.PROPERTY_TEXT_ALIGN)) { String textAlign = d.getString(TiC.PROPERTY_TEXT_ALIGN); TiUIHelper.setAlignment(cb, textAlign, null); } if (d.containsKey(TiC.PROPERTY_VERTICAL_ALIGN)) { String verticalAlign = d.getString(TiC.PROPERTY_VERTICAL_ALIGN); TiUIHelper.setAlignment(cb, null, verticalAlign); } cb.invalidate(); }
Example #29
Source File: CollectionViewProxy.java From TiCollectionView with MIT License | 5 votes |
public void handleCreationArgs(KrollModule createdInModule, Object[] args) { preloadSections = new ArrayList<CollectionSectionProxy>(); defaultValues.put(TiC.PROPERTY_DEFAULT_ITEM_TEMPLATE, "listDefaultTemplate"); defaultValues.put(TiC.PROPERTY_CASE_INSENSITIVE_SEARCH, true); super.handleCreationArgs(createdInModule, args); }
Example #30
Source File: CollectionViewTemplate.java From TiCollectionView with MIT License | 5 votes |
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; }