@Kroll.method
 public void remove(TableViewRowProxy rowProxy) {
   if (rowProxy != null) {
     rows.remove(rowProxy);
     if (rowProxy.getParent() == this) {
       rowProxy.setParent(null);
     }
   }
 }
 @Override
 public void setActivity(Activity activity) {
   super.setActivity(activity);
   if (rows != null) {
     for (TableViewRowProxy row : rows) {
       row.setActivity(activity);
     }
   }
 }
 @Override
 public void releaseViews(boolean activityFinishing) {
   super.releaseViews(activityFinishing);
   if (rows != null) {
     for (TableViewRowProxy row : rows) {
       row.releaseViews(activityFinishing);
     }
   }
 }
 @Kroll.method
 public void add(TableViewRowProxy rowProxy) {
   if (rowProxy != null) {
     rows.add(rowProxy);
     if (rowProxy.getParent() == null) {
       rowProxy.setParent(this);
     }
   }
 }
 @Override
 public void releaseViews() {
   super.releaseViews();
   if (rows != null) {
     for (TableViewRowProxy row : rows) {
       row.releaseViews();
     }
   }
 }
 @Override
 public void eventListenerRemoved(String eventName, int count, KrollProxy proxy) {
   super.eventListenerRemoved(eventName, count, proxy);
   if (eventName.equals(TiC.EVENT_CLICK) && count == 0 && proxy == this) {
     for (TableViewSectionProxy section : getSections()) {
       for (TableViewRowProxy row : section.getRows()) {
         row.setLabelsClickable(false);
       }
     }
   }
 }
 @Kroll.method
 public void removeRowAt(int index) {
   if (index > -1 && index < rows.size()) {
     TableViewRowProxy rowProxy = rows.get(index);
     rows.remove(index);
     if (rowProxy.getParent() == this) {
       rowProxy.setParent(null);
     }
   } else {
     Log.e(TAG, "Index out of range. Unable to remove row at index " + index, Log.DEBUG_MODE);
   }
 }
  private TableViewRowProxy rowProxyFor(Object row) {
    TableViewRowProxy rowProxy = null;
    if (row instanceof KrollDict) {
      KrollDict d = (KrollDict) row;
      rowProxy = new TableViewRowProxy(getTiContext());
      rowProxy.handleCreationDict(d);
      rowProxy.setProperty(TiC.PROPERTY_CLASS_NAME, CLASSNAME_NORMAL);
      rowProxy.setProperty(TiC.PROPERTY_ROW_DATA, row);
    } else {
      rowProxy = (TableViewRowProxy) row;
    }

    rowProxy.setParent(this);
    return rowProxy;
  }
 @Kroll.method
 public void updateRowAt(int index, TableViewRowProxy row) {
   TableViewRowProxy oldRow = rows.get(index);
   if (row == oldRow) {
     return;
   }
   if (index > -1 && index < rows.size()) {
     rows.set(index, row);
     row.setParent(this);
     if (oldRow.getParent() == this) {
       oldRow.setParent(null);
     }
   } else {
     Log.e(TAG, "Index out of range. Unable to update row at index " + index, Log.DEBUG_MODE);
   }
 }
示例#10
0
 private void handleAppendRow(Object row) {
   TableViewRowProxy rowProxy = rowProxyFor(row);
   ArrayList<TableViewSectionProxy> sections = getSections();
   if (sections.size() == 0) {
     Object[] data = {rowProxy};
     processData(data);
   } else {
     TableViewSectionProxy lastSection = sections.get(sections.size() - 1);
     TableViewSectionProxy addedToSection = addRowToSection(rowProxy, lastSection);
     if (lastSection == null || !lastSection.equals(addedToSection)) {
       sections.add(addedToSection);
     }
     rowProxy.setProperty(TiC.PROPERTY_SECTION, addedToSection);
     rowProxy.setProperty(TiC.PROPERTY_PARENT, addedToSection);
   }
   getTableView().setModelDirty();
   updateView();
 }
 @Kroll.method
 public void insertRowAt(int index, TableViewRowProxy row) {
   if (index > -1 && index <= rows.size()) {
     rows.add(index, row);
     row.setParent(this);
   } else {
     Log.e(TAG, "Index out of range. Unable to insert row at index " + index, Log.DEBUG_MODE);
   }
 }
示例#12
0
 @Kroll.method
 public int getIndexByName(String name) {
   int index = -1;
   int idx = 0;
   if (name != null) {
     for (TableViewSectionProxy section : getSections()) {
       for (TableViewRowProxy row : section.getRows()) {
         String rname = TiConvert.toString(row.getProperty(TiC.PROPERTY_NAME));
         if (rname != null && name.equals(rname)) {
           index = idx;
           break;
         }
         idx++;
       }
       if (index > -1) {
         break;
       }
     }
   }
   return index;
 }
示例#13
0
 /**
  * If the row does not carry section information, it will be added to the currentSection. If it
  * does carry section information (i.e., a header), that section will be created and the row added
  * to it. Either way, whichever section the row gets added to will be returned.
  */
 private TableViewSectionProxy addRowToSection(
     TableViewRowProxy row, TableViewSectionProxy currentSection) {
   KrollDict d = row.getProperties();
   TableViewSectionProxy addedToSection = null;
   if (currentSection == null || d.containsKey(TiC.PROPERTY_HEADER)) {
     addedToSection = new TableViewSectionProxy(getTiContext());
   } else {
     addedToSection = currentSection;
   }
   if (d.containsKey(TiC.PROPERTY_HEADER)) {
     addedToSection.setProperty(TiC.PROPERTY_HEADER_TITLE, d.get(TiC.PROPERTY_HEADER));
   }
   if (d.containsKey(TiC.PROPERTY_FOOTER)) {
     addedToSection.setProperty(TiC.PROPERTY_FOOTER_TITLE, d.get(TiC.PROPERTY_FOOTER));
   }
   addedToSection.add(row);
   return addedToSection;
 }