@Override public void handleCreationDict(KrollDict options) { options = handleStyleOptions(options); if (langConversionTable != null) { KrollDict foundStrings = new KrollDict(); for (String key : langConversionTable.keySet()) { // if we have it already, ignore if (!options.containsKey(key)) { String convertKey = (String) langConversionTable.get(key); String langKey = (String) options.get(convertKey); if (langKey != null) { try { String localText = getLocalizedText(langKey); foundStrings.put(key, localText); } catch (TiRHelper.ResourceNotFoundException e) { Log.w(LCAT, "Localized text key '" + langKey + "' is invalid."); } } } } if (!(foundStrings.isEmpty())) { extend(foundStrings); options.putAll(foundStrings); } } options = handleStyleOptions(options); super.handleCreationDict(options); // TODO eventManager.addOnEventChangeListener(this); }
protected KrollDict handleStyleOptions(KrollDict options) { String viewId = getProxyId(); TreeSet<String> styleClasses = new TreeSet<String>(); // TODO styleClasses.add(getShortAPIName().toLowerCase()); if (options.containsKey(TiC.PROPERTY_ID)) { viewId = TiConvert.toString(options, TiC.PROPERTY_ID); } if (options.containsKey(TiC.PROPERTY_CLASS_NAME)) { String className = TiConvert.toString(options, TiC.PROPERTY_CLASS_NAME); for (String clazz : className.split(" ")) { styleClasses.add(clazz); } } if (options.containsKey(TiC.PROPERTY_CLASS_NAMES)) { Object c = options.get(TiC.PROPERTY_CLASS_NAMES); if (c.getClass().isArray()) { int length = Array.getLength(c); for (int i = 0; i < length; i++) { Object clazz = Array.get(c, i); if (clazz != null) { styleClasses.add(clazz.toString()); } } } } String baseUrl = getBaseUrlForStylesheet(); KrollDict dict = TiApplication.getInstance().getStylesheet(baseUrl, styleClasses, viewId); if (dict.size() > 0) { extend(dict); } if (DBG) { Log.d( LCAT, "trying to get stylesheet for base:" + baseUrl + ",classes:" + styleClasses + ",id:" + viewId + ",dict:" + dict); } if (dict != null) { // merge in our stylesheet details to the passed in dictionary // our passed in dictionary takes precedence over the stylesheet dict.putAll(options); return dict; } return options; }