[TIMOB-15408] Android: TableView/ListView behaves incorrectly when ScrollableView inside TableView/ListView
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 3.2.0 |
Fix Version/s | n/a |
Components | Android |
Labels | n/a |
Reporter | Ping Wang |
Assignee | Unknown |
Created | 2013-10-07T20:50:07.000+0000 |
Updated | 2018-02-28T20:04:02.000+0000 |
Description
After fixing TIMOB-13610, there are a few issues exposed on the Android platform.
1. Run the test case for tableview without
className: "scrollable"
. Scroll the first row to the green view. Scroll the tableview down to the bottom and then up to the top. Scroll the first row to other color again. The app crashes with the error "E/AndroidRuntime( 4744): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first."
2. Run the test case for tableview with/without className: "scrollable"
. Scroll the first row to the green view and then scroll the tableview up and down several times. The first row does not stay at the green view. Probably because the item views in the TableView get recycled when they are off screen.
-3.- Run the test case for listview. Scroll the first row to page 2. Expected behavior: page 2 is a yellow view. Actual behavior: page 2 is a white view. (TIMOB-13868)
4. Run the test case for listview. Scroll the first row to the green view and then scroll the listview up and down several times. The first row does not stay at the green view and the other rows do not stay at the blue views. Probably because the item views in the ListView get recycled when they are off screen.
--------------------- Test case for TableView ----------------------------
var win = Ti.UI.createWindow({
backgroundColor : 'white',
modal : false
});
var table = Ti.UI.createTableView();
var rowData = [];
for (var i = 0; i < 10; i++) {
var scrollable = Ti.UI.createScrollableView({
top : 0,
left : 0,
bottom : 0,
right : 0,
backgroundColor : 'orange',
views : [Ti.UI.createView({
backgroundColor : 'blue'
}), Ti.UI.createView({
backgroundColor : 'green'
}), Ti.UI.createView({
backgroundColor : 'yellow'
})]
});
var row = Ti.UI.createTableViewRow({
//className: "scrollable"
height : 300
});
row.add(scrollable);
rowData.push(row);
}
for (var i = 0; i < 40; i++) {
rowData.push(Ti.UI.createTableViewRow({
title : ("test2 " + i)
}));
}
table.data = rowData;
win.add(table);
win.open();
--------------------- Test case for ListView ----------------------------
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var plainTemplate = {
childTemplates: [
{
type: 'Ti.UI.ScrollableView',
bindId: 'scrollable',
properties: {
height: '300'
}
}
]
};
var listView = Ti.UI.createListView({
templates: { 'plain': plainTemplate },
defaultItemTemplate: 'plain'
});
var data = [];
for (var i = 0; i < 10; i++) {
data.push({
scrollable : { views : [Ti.UI.createView({
backgroundColor : 'blue'
}), Ti.UI.createView({
backgroundColor : 'green'
}), Ti.UI.createView({
backgroundColor : 'yellow'
})] }
});
}
var section = Ti.UI.createListSection({items: data});
listView.sections = [section];
win.add(listView);
win.open();
It is likely we will do the fixes for ListView in 3.2.1, but we might defer the fixes for TableView.
@Ingo: Actually the tableview fixes are the easier to fix (and one is actually not related to tableview), about one line change without any chance of regression. The listview fix is a lot harder i think, still great news if you can fix it soon
[~farfromrefuge] I would be curious to know what the one line fix is for TableView and how we can ensure it won't cause any regressions.
@Ingo: * the currentPage fix is about adding a new property TiC.PROPERTY_CURRENT_PAGE to onProcessProperties and onPropertyChange. That will allow the tableview and the listview to set the correct page when preparing a cell. No chance of regression (a bug though is always possible ;) ). I have it running just fine in my branch. * the problem with clearChildViews can be fixed in one line. This is not clean but has no chance of regression: just make sure it calls setView(null) for the scrollable "views". Now this is not clean. The way i did it was with some refactoring. clearChildViews was moved to TIViewProxy and is handled correctly by each class. This is the way to go but with refactoring there are always chance of regression. Now i am sorry i cant make a PR, my code is a lot too far from the master branch and PR are too hard to maintain. Though i think i have guided you enough for it to be easily fixed.
Issue No.1 reproduces Titanium SDK version 3.4.0 master, 3.2.0.GA Titanium Studio, build: 3.3.0.201407100905 Titanium Command-Line Interface CLI version 3.3.0, Android device : Motorola Moto G, Android version : 4.4.4