Java Code Examples for org.appcelerator.kroll.KrollDict#containsKey()
The following examples show how to use
org.appcelerator.kroll.KrollDict#containsKey() .
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: CameraViewProxy.java From Ti-Android-CameraView with MIT License | 6 votes |
@Override public void processProperties(KrollDict d) { super.processProperties(d); if(d.containsKey("save_location")){ SAVE = d.getString("save_location"); } if( d.containsKey("useFrontCamera") ){ Log.i(TAG, "Front Camera Property exists!"); FRONT_CAMERA = d.getBoolean("useFrontCamera"); } if( d.containsKey("pictureTimeout")){ PICTURE_TIMEOUT = d.getInt("pictureTimeout"); } if( d.containsKey("resolutionNamed") ){ RESOLUTION_NAME = d.getInt("resolutionNamed"); } }
Example 2
Source File: ViewProxy.java From TiTouchImageView with MIT License | 6 votes |
@Override public void processProperties(KrollDict props) { super.processProperties(props); if (props.containsKey("zoom")) { tiv.setZoom(TiConvert.toFloat(proxy.getProperty("zoom"))); } if (props.containsKey("image")) { handleImage(proxy.getProperty("image")); } if (props.containsKey("maxZoom")) { tiv.setMaxZoom(TiConvert.toFloat(proxy.getProperty("maxZoom"))); } if (props.containsKey("minZoom")) { tiv.setMinZoom(TiConvert.toFloat(proxy.getProperty("minZoom"))); } }
Example 3
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 4
Source File: ViewItem.java From TiCollectionView with MIT License | 6 votes |
/** * This method compares applied properties of a view and our data model to * generate a new set of properties we need to set. It is crucial for scrolling performance. * @param properties The properties from our data model * @return The difference set of properties to set */ public KrollDict generateDiffProperties(KrollDict properties) { diffProperties.clear(); for (String appliedProp : this.properties.keySet()) { if (!properties.containsKey(appliedProp)) { applyProperty(appliedProp, null); } } for (String property : properties.keySet()) { Object value = properties.get(property); if (CollectionView.MUST_SET_PROPERTIES.contains(property)) { applyProperty(property, value); continue; } Object existingVal = this.properties.get(property); if (existingVal == null || value == null || !existingVal.equals(value)) { applyProperty(property, value); } } return diffProperties; }
Example 5
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 6
Source File: DatePickerProxy.java From TiDialogs with MIT License | 5 votes |
@Override public void processProperties(KrollDict d) { super.processProperties(d); Calendar c = Calendar.getInstance(); if (d.containsKey("value")) { c.setTime((Date) d.get("value")); year = c.get(Calendar.YEAR); month = c.get(Calendar.MONTH); day = c.get(Calendar.DAY_OF_MONTH); } else { if (d.containsKey("year")) { year = d.getInt("year"); } else { year = c.get(Calendar.YEAR); } if (d.containsKey("month")) { month = d.getInt("month"); } else { month = c.get(Calendar.MONTH); } if (d.containsKey("day")) { day = d.getInt("day"); } else { day = c.get(Calendar.DAY_OF_MONTH); } } if (d.containsKey("okButtonTitle")) { okButtonTitle = d.getString("okButtonTitle"); } else { okButtonTitle = this.proxy.getActivity().getApplication().getResources().getString(R.string.ok); } if (d.containsKey("cancelButtonTitle")) { cancelButtonTitle = d.getString("cancelButtonTitle"); } else { cancelButtonTitle = this.proxy.getActivity().getApplication().getResources().getString(R.string.cancel); } }
Example 7
Source File: TimePickerProxy.java From TiDialogs with MIT License | 5 votes |
@Override public void processProperties(KrollDict d) { super.processProperties(d); Calendar c = Calendar.getInstance(); if (d.containsKey("value")) { c.setTime((Date) d.get("value")); hour = c.get(Calendar.HOUR_OF_DAY); minute = c.get(Calendar.MINUTE); } else { if (d.containsKey("hour")) { hour = d.getInt("hour"); } else { hour = c.get(Calendar.HOUR_OF_DAY); } if (d.containsKey("minute")) { minute = d.getInt("minute"); } else { minute = c.get(Calendar.MINUTE); } } if (d.containsKey("okButtonTitle")) { okButtonTitle = d.getString("okButtonTitle"); } else { okButtonTitle = this.proxy.getActivity().getApplication().getResources().getString(R.string.ok); } if (d.containsKey("cancelButtonTitle")) { cancelButtonTitle = d.getString("cancelButtonTitle"); } else { cancelButtonTitle = this.proxy.getActivity().getApplication().getResources().getString(R.string.cancel); } }
Example 8
Source File: ExampleProxy.java From NovarumBluetooth with MIT License | 5 votes |
@Override public void handleCreationDict(KrollDict options) { super.handleCreationDict(options); if (options.containsKey("message")) { Log.d(TAG, "example created with message: " + options.get("message")); } }
Example 9
Source File: DropdownProxy.java From actionbarextras with MIT License | 5 votes |
@Override public void handleCreationDict(KrollDict options) { final ActionBar actionBar = ((AppCompatActivity)getActivity()).getSupportActionBar(); final boolean keepTitle; if (options.containsKey("keepTitle")) { keepTitle = options.getBoolean("keepTitle"); }else{ keepTitle = false; } add(keepTitle); if (options.containsKey("titles")) { final String[] dropdownValues = options.getStringArray("titles"); ArrayAdapter<String> adapter = new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_spinner_item, android.R.id.text1, dropdownValues); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); actionBar.setListNavigationCallbacks(adapter, navigationListener); } if (options.containsKey("index")) { int activeItem = options.getInt("index"); setActiveItem(activeItem); } super.handleCreationDict(options); }
Example 10
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 11
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 12
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 13
Source File: ExampleProxy.java From TiCollectionView with MIT License | 5 votes |
@Override public void handleCreationDict(KrollDict options) { super.handleCreationDict(options); if (options.containsKey("message")) { Log.d(LCAT, "example created with message: " + options.get("message")); } }
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: CollectionViewTemplate.java From TiCollectionView with MIT License | 5 votes |
private void processProperties(KrollDict properties) { bindProxiesAndProperties(properties, true, null); if (properties.containsKey(TiC.PROPERTY_CHILD_TEMPLATES)) { processChildProperties(properties.get(TiC.PROPERTY_CHILD_TEMPLATES), rootItem); } }
Example 16
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; }
Example 17
Source File: CameraViewProxy.java From Ti-Android-CameraView with MIT License | 5 votes |
@Override public void handleCreationDict(KrollDict options) { super.handleCreationDict(options); if (options.containsKey("save_location")) { SAVE = options.getString("save_location"); } }
Example 18
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 19
Source File: TicroutonModule.java From TiCrouton with MIT License | 4 votes |
@Kroll.method public void show(KrollDict args) { Log.d(TAG, "show called"); final Crouton crouton; Activity activity; String text = ""; Style style = null; Builder config = new Configuration.Builder(); if (args.containsKey(TiC.PROPERTY_ACTIVITY)){ ActivityProxy activityProxy = (ActivityProxy) args.get(TiC.PROPERTY_ACTIVITY); activity = activityProxy.getActivity(); }else{ activity = TiApplication.getInstance().getCurrentActivity(); } if (args.containsKey(TiC.PROPERTY_TEXT)){ text = TiConvert.toString(args.get(TiC.PROPERTY_TEXT)); } if (args.containsKey(TiC.PROPERTY_STYLE)){ style = getStyle(TiConvert.toInt(args.get(TiC.PROPERTY_STYLE))); } if (args.containsKey(TiC.PROPERTY_COLOR)){ String color = (String) args.get(TiC.PROPERTY_COLOR); style = new Style.Builder() .setBackgroundColorValue(TiConvert.toColor(color)) .build(); } if (style == null){ style = Style.INFO; } crouton = Crouton.makeText(activity, text, style); if (args.containsKey(TiC.PROPERTY_DURATION)){ config.setDuration(TiConvert.toInt(args.get(TiC.PROPERTY_DURATION))); crouton.setConfiguration(config.build()); } TiUIHelper.runUiDelayedIfBlock(new Runnable() { @Override public void run() { crouton.show(); } }); }
Example 20
Source File: TicroutonModule.java From TiCrouton with MIT License | 4 votes |
@Kroll.method public Crouton make(KrollDict args) { Log.d(TAG, "make called"); Crouton crouton; Activity activity; String text = ""; Style style = null; Builder config = new Configuration.Builder(); if (args.containsKey(TiC.PROPERTY_ACTIVITY)){ ActivityProxy activityProxy = (ActivityProxy) args.get(TiC.PROPERTY_ACTIVITY); activity = activityProxy.getActivity(); }else{ activity = TiApplication.getInstance().getCurrentActivity(); } if (args.containsKey(TiC.PROPERTY_TEXT)){ text = TiConvert.toString(args.get(TiC.PROPERTY_TEXT)); } if (args.containsKey(TiC.PROPERTY_STYLE)){ style = getStyle(TiConvert.toInt(args.get(TiC.PROPERTY_STYLE))); } if (args.containsKey(TiC.PROPERTY_COLOR)){ String color = (String) args.get(TiC.PROPERTY_COLOR); style = new Style.Builder() .setBackgroundColorValue(TiConvert.toColor(color)) .build(); } if (style == null){ style = Style.INFO; } crouton = Crouton.makeText(activity, text, style); if (args.containsKey(TiC.PROPERTY_DURATION)){ config.setDuration(TiConvert.toInt(args.get(TiC.PROPERTY_DURATION))); crouton.setConfiguration(config.build()); } return crouton; }