Example #1
0
  @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 void processTemplates(KrollDict templates) {
   for (String key : templates.keySet()) {
     // Here we bind each template with a key so we can use it to look up later
     KrollDict properties = new KrollDict((HashMap) templates.get(key));
     TiListViewTemplate template = new TiListViewTemplate(key, properties);
     // Set type to template, for recycling purposes.
     template.setType(getItemType());
     templatesByBinding.put(key, template);
     // set parent of root item
     template.setRootParent(proxy);
   }
 }
Example #3
0
 public void setLocalizedText(String idPropertyName, String idPropertyValue) {
   if (langConversionTable == null) {
     return;
   }
   for (String propertyName : langConversionTable.keySet()) {
     String thisIdPropertyName = langConversionTable.getString(propertyName);
     if (idPropertyName.equals(thisIdPropertyName)) {
       try {
         String localText = getLocalizedText(idPropertyValue);
         setPropertyAndFire(propertyName, localText);
       } catch (ResourceNotFoundException e) {
         Log.w(LCAT, "Localized text key '" + idPropertyValue + "' is invalid.");
       }
       break;
     }
   }
 }
Example #4
0
  /**
   * 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 (TiListView.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
0
 public Set<String> minusKeys(final KrollDict that) {
   Set<String> keys = new HashSet<String>(keySet());
   Set<String> thatkeys = that.keySet();
   keys.removeAll(thatkeys);
   return keys;
 }