{ "id": "151766", "key": "TIMOB-20116", "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": "17706", "name": "Release 5.4.0", "archived": false, "released": true, "releaseDate": "2016-08-11" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-04-05T03:31:23.000+0000", "created": "2015-10-06T19:23:15.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "removeview", "scrollableview" ], "versions": [ { "id": "16904", "description": "Release 5.0.2", "name": "Release 5.0.2", "archived": true, "released": true, "releaseDate": "2015-10-01" }, { "id": "17532", "name": "Release 5.1.1", "archived": false, "released": true, "releaseDate": "2015-11-24" } ], "issuelinks": [ { "id": "51217", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "159255", "key": "TIMOB-23134", "fields": { "summary": "Android: ScrollableView crashed when setViews([])", "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": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2016-06-24T18:41:04.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": "This is happening only in the android platform. Seems like when you call the ScrollableView.removeView() method it automatically jumps to the previous view if you're currently viewing the one you're trying to delete. However, that fires an exception.\r\nHow to reproduce:\r\n\r\n* Create an Android-enabled project with a single, main view.\r\n* Add to that view a ScrollableView and a Button below it.\r\n* Add 3 empty views to the ScrollableView.\r\n* Add an event to the button which fires the following code:\r\n{code:javascript}\r\n_.each($.scrollableView.getViews(), function(view) {\r\n $.scrollableView.removeView(view);\r\n});\r\n{code}\r\n\r\n* Click the button with the view number 1 focused: it will work.\r\n* Reopen the app (so the views get added again), browse to the 3rd view and click the button.\r\nIt will throw this exception:\r\n\r\n{code:java}\r\n[ERROR] : TiApplication: (main) [47704,48391] Sending event: exception on thread: main msg:java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1; Titanium 5.0.3,2015/10/02 00:31,d4496fe\r\n[ERROR] : TiApplication: java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1\r\n[ERROR] : TiApplication: \tat java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)\r\n[ERROR] : TiApplication: \tat java.util.ArrayList.get(ArrayList.java:308)\r\n[ERROR] : TiApplication: \tat ti.modules.titanium.ui.widget.TiUIScrollableView$2.onPageSelected(TiUIScrollableView.java:159)\r\n[ERROR] : TiApplication: \tat android.support.v4.view.ViewPager.scrollToItem(ViewPager.java:578)\r\n[ERROR] : TiApplication: \tat android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:555)\r\n[ERROR] : TiApplication: \tat android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:513)\r\n[ERROR] : TiApplication: \tat android.support.v4.view.ViewPager.dataSetChanged(ViewPager.java:912)\r\n[ERROR] : TiApplication: \tat android.support.v4.view.ViewPager$PagerObserver.onChanged(ViewPager.java:2826)\r\n[ERROR] : TiApplication: \tat android.database.DataSetObservable.notifyChanged(DataSetObservable.java:37)\r\n[ERROR] : TiApplication: \tat android.support.v4.view.PagerAdapter.notifyDataSetChanged(PagerAdapter.java:276)\r\n[ERROR] : TiApplication: \tat ti.modules.titanium.ui.widget.TiUIScrollableView.removeView(TiUIScrollableView.java:350)\r\n[ERROR] : TiApplication: \tat ti.modules.titanium.ui.ScrollableViewProxy.handleMessage(ScrollableViewProxy.java:131)\r\n[ERROR] : TiApplication: \tat android.os.Handler.dispatchMessage(Handler.java:98)\r\n[ERROR] : TiApplication: \tat android.os.Looper.loop(Looper.java:135)\r\n[ERROR] : TiApplication: \tat android.app.ActivityThread.main(ActivityThread.java:5254)\r\n[ERROR] : TiApplication: \tat java.lang.reflect.Method.invoke(Native Method)\r\n[ERROR] : TiApplication: \tat java.lang.reflect.Method.invoke(Method.java:372)\r\n[ERROR] : TiApplication: \tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)\r\n[ERROR] : TiApplication: \tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)\r\n{code}\r\n\r\nHow i've solved it:\r\nBefore removing the ScrollableView views, i've used this method:\r\n\r\n{code:javascript}\r\n$.scrollableView.scrollToView($.scrollableView.getViews()[0]);\r\n{code}\r\n\r\n", "attachment": [], "flagged": false, "summary": "Android - ScrollableView removeView(): java.lang.IndexOutOfBoundsException: Invalid index X, size is X", "creator": { "name": "rdperottoni", "key": "rdperottoni", "displayName": "Rodolfo Perottoni", "active": true, "timeZone": "Australia/Brisbane" }, "subtasks": [], "reporter": { "name": "rdperottoni", "key": "rdperottoni", "displayName": "Rodolfo Perottoni", "active": true, "timeZone": "Australia/Brisbane" }, "environment": "Mac OS X 10.10.5\r\nTi SDK 5.0.3.v20151002003129\r\nStudio 4.3.0.201509151348", "closedSprints": [ { "id": 614, "state": "closed", "name": "2016 Sprint 07 SDK", "startDate": "2016-03-26T00:38:56.432Z", "endDate": "2016-04-09T00:38:00.000Z", "completeDate": "2016-04-11T04:41:08.231Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "381295", "author": { "name": "falko", "key": "falko", "displayName": "Andrey Tkachenko", "active": true, "timeZone": "Europe/Moscow" }, "body": "Friday PR: https://github.com/appcelerator/titanium_mobile/pull/7904\r\n\r\nTest code: \r\n\r\nindex.xml\r\n{code:xml}\r\n\r\n\t\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\r\n\r\n{code}\r\n\r\nindex.js\r\n{code:javascript}\r\nfunction doClear(e) {\r\n _.each($.scrollableView.getViews(), function(view) {\r\n \t$.scrollableView.removeView(view);\r\n });\r\n}\r\n\r\nfunction doClearSecond() {\r\n\t$.scrollableView.removeView($.scrollableView.getViews()[1]);}\r\n$.index.open();\r\n{code}\r\n\r\n", "updateAuthor": { "name": "falko", "key": "falko", "displayName": "Andrey Tkachenko", "active": true, "timeZone": "Europe/Moscow" }, "created": "2016-04-01T14:17:11.000+0000", "updated": "2016-04-01T14:50:04.000+0000" }, { "id": "381669", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Tested code with test case above. Working as expected.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-04-05T03:23:03.000+0000", "updated": "2016-04-05T03:23:03.000+0000" }, { "id": "381674", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR https://github.com/appcelerator/titanium_mobile/pull/7904 Merged with test cases in TIMOB-23134 and TIMOB-20116", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-04-05T03:31:04.000+0000", "updated": "2016-04-05T03:31:04.000+0000" }, { "id": "389045", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix.\r\n\r\n{{removeView()}} does not give a {{java.lang.IndexOutOfBoundsException}}.\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.7.0.201606150733\r\nTi SDK : 5.4.0.v20160617074028\r\nTi CLI : 5.0.9\r\nAlloy : 1.9.0\r\nMAC El Capitan : 10.11.4\r\nAppc NPM : 4.2.7-2\r\nAppc CLI : 5.4.0-18\r\nNode: 4.4.4\r\nNexus 6 - Android 6.0.1", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-06-24T18:40:53.000+0000", "updated": "2016-06-24T18:40:53.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }