[TIMOB-2344] Android: Crash when hiding Switch
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:58:50.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.5.0 M02 |
Components | Android |
Labels | android, android_refactor, defect, regression |
Reporter | Nathaniel McCallum |
Assignee | Don Thorp |
Created | 2011-04-15T03:17:15.000+0000 |
Updated | 2011-04-17T01:58:50.000+0000 |
Description
var win = Ti.UI.createWindow({
top: 0, left: 0, right: 0, bottom: 0,
backgroundColor: 'black'
});
var data = [];
var row = Ti.UI.createTableViewRow({title: "Test Row", hasChild: true});
data.push(row);
var tbl = Ti.UI.createTableView({
data: data,
top: 100, left: 0
});
win.add(tbl);
var menu = Ti.UI.Android.OptionMenu.createMenu();
var editBtn = Ti.UI.createButton({
title: 'Edit',
top: 0, left: 0
});
editBtn.addEventListener('click', function() {
for (var i in tbl.data) {
for (var j=0 ; j < tbl.data[i].rowCount ; j++) {
var row = tbl.data[i].rowAtIndex(j);
if (!row.cb) {
row.cb = Ti.UI.createSwitch({
visible: !row.hasChild,
style: Ti.UI.Android.SWITCH_STYLE_CHECKBOX,
right: -5, // Negate the built-in pad
});
row.add(row.cb);
}
row.hasChild = !row.hasChild;
row.cb.visible = !row.cb.visible;
}
}
tbl.data = tbl.data;
});
win.add(editBtn);
win.open();
Click the menu button once, everything toggles as expected. Click it a second time, crash.
W/KrollConverter( 3298): (kroll$3) [3470,11710] Unhandled type
conversion: value: [object TiUITableViewSection] type:
ti.modules.titanium.ui.TableViewSectionProxy, invocation:
[setProperty UI.TableView.data
ti.modules.titanium.ui.TableViewProxyBindingGen$2@48360280]
F/dalvikvm( 3298): Exception!!! threadid=1: thread exiting with
uncaught exception (group=0x4001d940)
(from [22eaec7f7d8c46231e08308258450575a5add5b9]) Switch now acts more intelligently when it's "style" attribute is changed. Don't recreate row proxy views if the convertedView is the same as the item's existing view. Remove / cleanup stale views from the row proxy view when setRowData is called. added a test for toggling hasChild / row proxy child views [#2344 state:fixed-in-qa] https://github.com/appcelerator/titanium_mobile/commit/22eaec7f7d8c46231e08308258450575a5add5b9"> https://github.com/appcelerator/titanium_mobile/commit/22eaec7f7d8c...
(from [e18980e31ba5c0e061da3ababd711467471bffeb]) pre-seed a relatively large number of row types so we can avoid calling setAdapter to tell the ListView about new row types (which causes all kinds of memory / model havoc). added a new forceCreateView in TiViewProxy to simply assign the internal view reference to a new instance, rather than forcefully tearing down the existing view. this fixes the className redrawing bug when the ListView recycler shuffles reused view instances [#1971 state:fixed-in-qa] [#2377 state:fixed-in-qa] [#2344] https://github.com/appcelerator/titanium_mobile/commit/e18980e31ba5c0e061da3ababd711467471bffeb"> https://github.com/appcelerator/titanium_mobile/commit/e18980e31ba5...
Titanium SDK version: 1.5.0 (12/03/10 09:29 33c2058) g2 (2.2) sim (2.1)