{ "id": "106631", "key": "TIMOB-12114", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "15498", "description": "2013 Sprint 12 API", "name": "2013 Sprint 12 API", "archived": true, "released": true, "releaseDate": "2013-06-17" }, { "id": "15110", "description": "2013 Sprint 12", "name": "2013 Sprint 12", "archived": true, "released": true, "releaseDate": "2013-06-17" }, { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-06-04T23:12:09.000+0000", "created": "2012-12-17T15:16:38.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "community", "exalture", "module_tableview", "qe-testadded" ], "versions": [ { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" }, { "id": "14162", "description": "Release 3.1.0", "name": "Release 3.1.0", "archived": true, "released": true, "releaseDate": "2013-04-16" } ], "issuelinks": [ { "id": "29144", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "115108", "key": "TIMOB-14018", "fields": { "summary": "Android: 'longpress' on tableView with headerView but no headerTitle returns incorrect index and might lead to a crash", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "updated": "2014-06-19T12:44:26.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h3. Problem description\r\n\r\nIf the tableview has a header, e.index returns the incorrect index for the 'longpress' event.\r\n\r\nIf the first row is long-pressed, then e.index == 1 instead of 0. 'click' returns the correct index. If the last row is long-pressed, the SDK crashes with an IndexOutOfBoundsException. If the TableView is created without a headerView, the index values are correct.\r\n\r\nOnly reproducible on TiSDK 3.0 as with a previous version e.index is undefined. \r\nWorks fine on iOS.\r\n\r\n\r\nh3. Steps to reproduce\r\n{code}\r\nvar _self = Ti.UI.createWindow({\r\n\tbackgroundColor : '#fff',\r\n\theight : Ti.UI.FILL,\r\n\twidth : Ti.UI.FILL\r\n});\r\nvar title = \"TableView Bug\";\r\nvar win = Ti.UI.createView({});\r\n_self.add(win);\r\n\r\nvar table = Ti.UI.createTableView({\r\n\theaderTitle : title\r\n});\r\nvar headerView = Ti.UI.createView({\r\n\tbackgroundColor : '#444'\r\n});\r\nvar titleLabel = Ti.UI.createLabel({\r\n\twidth : _self.width,\r\n\ttextAlign : 'center',\r\n\tcolor : '#eee'\r\n});\r\nheaderView.add(titleLabel);\r\ntitleLabel.text = \"Title text\";\r\ntable.setHeaderView(headerView);\r\n\r\nvar data = [];\r\ndata.push(Ti.UI.createTableViewRow({\r\n\ttitle : \"Row 0\"\r\n}));\r\ndata.push(Ti.UI.createTableViewRow({\r\n\ttitle : \"Row 1\"\r\n}));\r\ndata.push(Ti.UI.createTableViewRow({\r\n\ttitle : \"Row 2\"\r\n}));\r\ndata.push(Ti.UI.createTableViewRow({\r\n\ttitle : \"Row 3\"\r\n}));\r\ntable.setData(data);\r\n\r\nwin.add(table);\r\n\r\nvar label = Ti.UI.createLabel({\r\n\theight : '40dp',\r\n\tbottom : 0,\r\n\ttext : \"Label\"\r\n});\r\nwin.add(label);\r\n\r\ntable.addEventListener('click', function(e) {\r\n\tTi.API.info(\"#### table - row \" + e.index + \" clicked\")\r\n});\r\ntable.addEventListener('longpress', function(e) {\r\n\tTi.API.info(\"#### table - row \" + e.index + \" longpressed\")\r\n});\r\n\r\n_self.open();\r\n\r\n{code}\r\n\r\n\r\nPressing and long-pressing on the rows shows the index being returned.\r\nLong pressing the last row causes the crash:\r\n\r\n==\r\nE/AndroidRuntime( 8867): java.lang.IndexOutOfBoundsException: Invalid index 5, size is 5\r\nE/AndroidRuntime( 8867): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)\r\nE/AndroidRuntime( 8867): at java.util.ArrayList.get(ArrayList.java:304)\r\nE/AndroidRuntime( 8867): at ti.modules.titanium.ui.widget.tableview.TiTableView.getItemAtPosition(TiTableView.java:411)\r\nE/AndroidRuntime( 8867): at ti.modules.titanium.ui.TableViewProxy.fireEvent(TableViewProxy.java:149)\r\nE/AndroidRuntime( 8867): at org.appcelerator.titanium.view.TiUIView$3.onLongPress(TiUIView.java:1156)\r\nE/AndroidRuntime( 8867): at android.view.GestureDetector.dispatchLongPress(GestureDetector.java:1451)\r\nE/AndroidRuntime( 8867): at android.view.GestureDetector.access$200(GestureDetector.java:50)\r\nE/AndroidRuntime( 8867): at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:319)\r\nE/AndroidRuntime( 8867): at android.os.Handler.dispatchMessage(Handler.java:99)\r\nE/AndroidRuntime( 8867): at android.os.Looper.loop(Looper.java:137)\r\nE/AndroidRuntime( 8867): at android.app.ActivityThread.main(ActivityThread.java:4898)\r\nE/AndroidRuntime( 8867): at java.lang.reflect.Method.invokeNative(Native Method)\r\nE/AndroidRuntime( 8867): at java.lang.reflect.Method.invoke(Method.java:511)\r\nE/AndroidRuntime( 8867): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)\r\nE/AndroidRuntime( 8867): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)\r\nE/AndroidRuntime( 8867): at dalvik.system.NativeStart.main(Native Method)\r\n\r\n\r\n\r\n", "attachment": [ { "id": "34209", "filename": "TestTableView.js", "author": { "name": "pete@azuer.co.uk", "key": "pete@azuer.co.uk", "displayName": "Peter Colman", "active": true, "timeZone": "Europe/London" }, "created": "2012-12-17T15:16:38.000+0000", "size": 1218, "mimeType": "application/javascript" } ], "flagged": false, "summary": "Android: 'longpress' on tableView with headerView returns incorrect index and might lead to a crash", "creator": { "name": "pete@azuer.co.uk", "key": "pete@azuer.co.uk", "displayName": "Peter Colman", "active": true, "timeZone": "Europe/London" }, "subtasks": [], "reporter": { "name": "fcasali", "key": "fcasali", "displayName": "Federico Casali", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK 3.0.0.GA\r\nAndroid SDK tested 4.2.1 (Nexus Galaxy) ", "comment": { "comments": [ { "id": "232792", "author": { "name": "pete@azuer.co.uk", "key": "pete@azuer.co.uk", "displayName": "Peter Colman", "active": true, "timeZone": "Europe/London" }, "body": "Does anyone have any idea when or if this problem will be fixed or a patch available?", "updateAuthor": { "name": "pete@azuer.co.uk", "key": "pete@azuer.co.uk", "displayName": "Peter Colman", "active": true, "timeZone": "Europe/London" }, "created": "2012-12-30T15:45:25.000+0000", "updated": "2012-12-30T15:45:25.000+0000" }, { "id": "241947", "author": { "name": "jithinv@exalture.com", "key": "jithinv@exalture.com", "displayName": "jithinpv", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Issue reproduces with\n\nTitanium Studio, build: 3.0.1.201212181159\nTitanium SDK version: 3.1.0 (03/11/13 15:43 0c88429)\nTitanium SDK version: 3.0.2 (02/07/13 16:46 a4def81)\nDevice: Samsung galaxy s duos Android version: 4.0.4\nAndroid Emulator: Android SDK version: 2.2 \n", "updateAuthor": { "name": "jithinv@exalture.com", "key": "jithinv@exalture.com", "displayName": "jithinpv", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-03-13T12:20:08.000+0000", "updated": "2013-03-13T12:20:08.000+0000" }, { "id": "246888", "author": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Reduce index by 1 if headerview is present\r\nhttps://github.com/appcelerator/titanium_mobile/pull/4139", "updateAuthor": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-04-10T17:43:42.000+0000", "updated": "2013-04-10T17:43:42.000+0000" }, { "id": "253992", "author": { "name": "jicks83", "key": "jicks83", "displayName": "Jick Steen", "active": true, "timeZone": "Europe/Berlin" }, "body": "The app is still crashing on latest 3.2 build if you remove the headerTitle. Tried it on a Samsung Galaxy S2 with Android 4.1.2.\r\n\r\nCode to reproduce:\r\n\r\n{code}\r\nvar _self = Ti.UI.createWindow({\r\n backgroundColor : '#fff',\r\n height : Ti.UI.FILL,\r\n width : Ti.UI.FILL\r\n});\r\n_self.open();\r\n\r\nvar table = Ti.UI.createTableView();\r\n\r\nvar headerView = Ti.UI.createView({\r\n backgroundColor : '#444', visible: false, height: 0\r\n});\r\nvar titleLabel = Ti.UI.createLabel({\r\n width : _self.width,\r\n textAlign : 'center',\r\n color : '#eee',\r\n text: \"Title text\"\r\n});\r\nheaderView.add(titleLabel);\r\ntable.setHeaderView(headerView);\r\n\r\nvar row = Ti.UI.createTableViewRow({title: 'Press me long'});\r\ntable.setData([row]);\r\n \r\n_self.add(table);\r\n \r\ntable.addEventListener('click', function(e) {\r\n Ti.API.info(\"#### table - row \" + e.index + \" clicked\")\r\n});\r\ntable.addEventListener('longpress', function(e) {\r\n Ti.API.info(\"#### table - row \" + e.index + \" longpressed\")\r\n});\r\n \r\n{code}", "updateAuthor": { "name": "jicks83", "key": "jicks83", "displayName": "Jick Steen", "active": true, "timeZone": "Europe/Berlin" }, "created": "2013-05-25T10:17:36.000+0000", "updated": "2013-05-25T10:17:36.000+0000" }, { "id": "254639", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Going to reopen this one, since it seems the issue is still there.", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-29T20:51:54.000+0000", "updated": "2013-05-29T20:51:54.000+0000" }, { "id": "255391", "author": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "body": "\r\nAdditional fix\r\nRemoved the redundant index decrement from the longClickHandler also.\r\n\r\nhttps://github.com/appcelerator/titanium_mobile/pull/4347", "updateAuthor": { "name": "sunila", "key": "sunila", "displayName": "Sunila", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-06-01T06:30:09.000+0000", "updated": "2013-06-01T06:30:09.000+0000" }, { "id": "274942", "author": { "name": "pmishra", "key": "pmishra", "displayName": "Paras Mishra", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Longpress event is returning the correct index.\r\n\r\nVerified fix on:\r\nDevice : Google Nexus 7, Android Version: 4.3\r\nSDK: 3.2.0.v20131013140318\r\nCLI version : 3.2.0\r\nOS : MAC OSX 10.8.4\r\nAlloy : 1.2.2\r\nAppcelerator Studio, build: 3.2.0.201310112258\r\nXCode : 5", "updateAuthor": { "name": "pmishra", "key": "pmishra", "displayName": "Paras Mishra", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-10-14T10:36:21.000+0000", "updated": "2013-10-14T10:36:21.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }