[AC-6646] [Android] Scrollable View `currentPage` Property Not Updated After Being Assigned
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Open |
| Resolution | Unresolved |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Titanium SDK & CLI |
| Labels | android, parity |
| Reporter | Ma Wenli |
| Assignee | Abir Mukherjee |
| Created | 2020-12-15T08:43:17.000+0000 |
| Updated | 2020-12-15T10:23:56.000+0000 |
Description
If
currentPage property of scrollable view is assigned in the code, the value doesn't seem to get updated immediately on Android. This issue can be reproduced by creating a new project with the following sample code, building the project with Titanium SDK 9.3.0.GA, and running the app on an *_Android_* device:
var win = Ti.UI.createWindow();
var v0 = Ti.UI.createView({
backgroundColor: 'red'
});
v0.add(Ti.UI.createLabel({
color: 'white',
text: 'Page index = 0'
}));
var v1 = Ti.UI.createView({
backgroundColor: 'blue'
});
v1.add(Ti.UI.createLabel({
color: 'white',
text: 'Page index = 1'
}));
var v2 = Ti.UI.createView({
backgroundColor: 'green'
});
v2.add(Ti.UI.createLabel({
color: 'white',
text: 'Page index = 2'
}));
var scrollableView = Ti.UI.createScrollableView({
views: [v0, v1, v2],
height: Ti.UI.FILL,
width: Ti.UI.FILL
});
win.add(scrollableView);
// Note that currentPage property of scrollable view is assigned here
scrollableView.currentPage = 1;
Ti.API.info('currentPage property of scrollable view is: ' + scrollableView.currentPage);
win.open();
What I observed in the console was a message saying "[INFO] currentPage property of scrollable view is: 0", but currentPage should have been updated to 1 already.
FYI, when I run the above sample code on an iOS device, the console output would be "[INFO] currentPage property of scrollable view is: 1" instead, which was the expected behaviour.
I can reproduce this issue back to 8.3.1.GA, it's possible this might be some form of timing issue on Android as adding even a small timeout to the log like below will log the correct value
setTimeout(() => { Ti.API.info('currentPageproperty of scrollable view is after timeout: ' + scrollableView.currentPage); }, 50)