{ "id": "117130", "key": "TIMOB-14545", "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": [], "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2014-04-09T21:48:21.000+0000", "created": "2013-07-12T11:04:21.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "listview", "parity" ], "versions": [ { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "issuelinks": [ { "id": "36533", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "117131", "key": "TIMOB-14546", "fields": { "summary": "Android: ListView appendSection to empty ListView throws exception", "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": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-20T22:19:12.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": "If a ListSection is not initialized with items, any access to it crashes Android app with null pointer exception. This makes loops such as \r\n{code:javascript}\r\nfor (var i = 0; i < listView.sections[0].items.length; i++) { // ...\r\n{code}\r\ndangerous on Android, with annoying bookkeeping required. It works as expected on iOS, with no issue. See test code below:\r\n{code:javascript}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : 'white'\r\n});\r\nvar listView = Ti.UI.createListView({\r\n\ttop : '150dp'\r\n});\r\n\r\nvar btn = Ti.UI.createButton({\r\n\ttop : '45dp',\r\n\twidth : '300dp',\r\n\theight : '40dp',\r\n\ttitle : 'Android crash items.length'\r\n});\r\nbtn.addEventListener('click', function() {\r\n\tlistView.removeAllChildren();\r\n\tvar fruitSection = Ti.UI.createListSection({\r\n\t\theaderTitle : 'Fruits'\r\n\t});\r\n\tvar sections = [];\r\n\tsections.push(fruitSection);\r\n\tlistView.sections = sections;\r\n\tTi.API.info('no items in section, Android will crash evaluating items.length in next line');\r\n\tfor (var i = 0; i < listView.sections[0].items.length; i++) {\r\n\t\tTi.API.info('this will not print');\r\n\t}\r\n\talert('you will see this alert on iOS but not Android');\r\n});\r\nwin.add(btn);\r\nwin.add(listView);\r\nwin.open();\r\n{code}\r\n", "attachment": [], "flagged": false, "summary": "Android: Accessing empty ListView section crashes app", "creator": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "subtasks": [], "reporter": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "environment": "SDK 3.1.1.GA, Nexus S 4.1.2", "comment": { "comments": [ { "id": "261697", "author": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested and confirmed on Samsung Galaxy S2 2.3.6 with Ti SDK 3.2 CI.", "updateAuthor": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-12T23:20:17.000+0000", "updated": "2013-07-12T23:20:17.000+0000" }, { "id": "283938", "author": { "name": "hntn", "key": "hntn", "displayName": "Tadatoshi Hanazaki", "active": true, "timeZone": "Asia/Tokyo" }, "body": "I also.\r\n\r\nGalaxy S4 4.2.2 with Ti SDK 3.1.3", "updateAuthor": { "name": "hntn", "key": "hntn", "displayName": "Tadatoshi Hanazaki", "active": true, "timeZone": "Asia/Tokyo" }, "created": "2013-12-12T06:33:16.000+0000", "updated": "2013-12-12T06:33:16.000+0000" }, { "id": "300421", "author": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "updateAuthor": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2014-04-09T21:08:21.000+0000", "updated": "2014-04-09T21:08:21.000+0000" }, { "id": "414080", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as duplicate.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-20T22:19:12.000+0000", "updated": "2017-03-20T22:19:12.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }