Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1319] [PATCH] Class cast exception in TableViewRowProxy.java in fireEvent

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:55:51.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.4.0
ComponentsAndroid
Labelsandroid, defect, tableview
ReporterJoel Boehland
AssigneeDon Thorp
Created2011-04-15T02:49:15.000+0000
Updated2011-04-17T01:55:51.000+0000

Description

TableViewRowProxy.fireEvent assumes that its parent is a TableViewProxy, when it can also be a TableViewSectionProxy object. If you fire an event from a row contained in a TableViewSection, it will cause a ClassCastException to be raised and the app will die. The following changes in my local repo fixed the problem:

diff --git a/android/modules/ui/src/ti/modules/titanium/ui/TableViewRowProxy.java b/android/modules/ui/src/ti/modules/titanium/ui/TableViewRowProxy.java
index a415c32..f1842db 100644
--- a/android/modules/ui/src/ti/modules/titanium/ui/TableViewRowProxy.java +++ b/android/modules/ui/src/ti/modules/titanium/ui/TableViewRowProxy.java @@ -87,8 +87,14 @@ public class TableViewRowProxy extends TiViewProxy

@Override
public boolean fireEvent(String eventName, TiDict data) {
    if (eventName.equals("click")) {
  •                  TableViewProxy table = null;
        // inject row click data for events coming from row children
    
  •     TableViewProxy table = (TableViewProxy)getParent();
    
  •                  if(getParent() instanceof TableViewProxy) {
    
  •                      table = (TableViewProxy)getParent();
    
  •                  }
    
  •     if(getParent() instanceof TableViewSectionProxy) {
    
  •                      table = (TableViewProxy)getParent().getParent();
    
  •                  }
        Item item = tableViewItem.getRowData();
        if (table != null && item != null) {
            TableViewModel model = table.getTableView().getModel();
    

Attachments

FileDateSize
gdiff.txt2011-04-15T02:49:15.000+00001154

Comments

  1. Joel Boehland 2011-04-15

    Apologies for the badly-formatted patch that I inlined in the original message. Please see the attached patch instead.

  2. Marshall Culpepper 2011-04-15

    (from [c580ff0f0ed719c35f65a7db75236540b7d8b187]) go up the tree to find the row's TableView parent (sometimes the immediate parent is a section) [#1319 state:resolved] http://github.com/appcelerator/titanium_mobile/commit/c580ff0f0ed719c35f65a7db75236540b7d8b187"> http://github.com/appcelerator/titanium_mobile/commit/c580ff0f0ed71...

JSON Source