[TIMOB-9474] Android: ScrollableView throws exception when using scrollToView()
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-06-08T17:41:45.000+0000 |
Affected Version/s | Release 2.1.0 |
Fix Version/s | Release 2.1.0, Sprint 2012-12 API |
Components | Android |
Labels | api, regression |
Reporter | Josh Roesslein |
Assignee | Josh Roesslein |
Created | 2012-06-08T15:11:26.000+0000 |
Updated | 2012-06-18T15:37:10.000+0000 |
Description
Trying to use scrollToView() on a ScrollableView sometimes results in an exception being thrown.
This appears to be triggered by creating the ScrollableView and passing a "currentPage" parameter.
This regression appears in the KS Base UI > Views > Scroll Views > Scrollable View.
Try scrolling to the next view by using the arrows on the bottom (these call scrollToView()).
Standalone test case
var win = Ti.UI.createWindow({layout: 'vertical'});
var views = ['blue', 'red', 'yellow'].map(function(color) {
return Ti.UI.createView({backgroundColor: color});
});
var scrollable = Ti.UI.createScrollableView({
height: '80%',
currentPage: 1,
views: views
});
win.add(scrollable);
var controls = Ti.UI.createView({
height: '20%'
});
win.add(controls);
var currentView = 1;
var prevButton = Ti.UI.createButton({
title: "Prev",
left: 10,
width: 200
});
controls.add(prevButton);
prevButton.addEventListener('click', function() {
if (currentView === 0) return;
scrollable.scrollToView(--currentView);
});
var nextButton = Ti.UI.createButton({
title: "Next",
right: 10,
width: 200
});
controls.add(nextButton);
nextButton.addEventListener('click', function() {
if (currentView == (scrollable.views.length - 1)) return;
var view = scrollable.views[++currentView];
scrollable.scrollToView(view);
});
scrollable.addEventListener('scroll', function(e) {
currentView = e.currentPage;
});
win.open();
Run the test case and try switching views by using the "next" or "prev" buttons.
Expected: Views change without any crash.
Sent [PR #2364](https://github.com/appcelerator/titanium_mobile/pull/2364) to fix regression.
Closing issue Tested with Ti Studio build 2.1.0.201206172244 Ti Mobile SDK2.1.0.v20120618134156 hash r00905cd0 OSX Lion 10.7.3 Nexus S OS 4.0.4 The expected behavior is shown