[TIMOB-25903] Android: TableView.updateRow() not working in 7.1.0 if "run-on-main-thread" is false
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-03-27T23:30:02.000+0000 |
Affected Version/s | Release 7.1.0 |
Fix Version/s | Release 7.1.1 |
Components | Android |
Labels | android, regression, tableview, updateRow |
Reporter | Carlos Henrique Zinato |
Assignee | Yordan Banev |
Created | 2018-03-23T17:18:19.000+0000 |
Updated | 2018-04-23T18:00:39.000+0000 |
Description
Updating a tableViewRow with updateRow method doesn't update desired row on Android using Titanium SDK 7.1.0.GA. It works fine on SDK 7.0.3.v20180226072443 and 6.3.1
On iOS it works on every mentioned SDK.
*update*: It is something regarding "run-on-main-thread". Having it turned off blocks row of being updated. Is there a reason for this?
How to test it:
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var rowData = [];
var row = Ti.UI.createTableViewRow({
height: 120,
title: 'ROW #00'
});
rowData.push(row);
var table = Ti.UI.createTableView({
top: 50,
height: 120,
data: rowData
});
table.addEventListener( 'click', function(e) {
console.log(' ***** click on table ');
});
win.add(table);
var bt = Ti.UI.createButton({
top: 200,
title: 'UPDATE ROW'
});
bt.addEventListener('click',function(e){
var newRow = Ti.UI.createTableViewRow({
height: 120,
title: 'NEW ROW'
});
table.updateRow(0,newRow);
});
win.add(bt);
win.open();
Expected result: Row on index 0 should be updated with a new one with the title "NEW ROW"
Current result: First row is not updated and the click event is not fired at all
PR (7.1.x): https://github.com/appcelerator/titanium_mobile/pull/9963
FR Passed. PR's merged.
Verified the fix with SDK 7.2.0.v20180409070600 & 7.1.1.v20180406141533. Closing. Studio Ver: 5.1.0 SDK Ver: 7.2.0.v20180409070600 OS Ver: 10.13.2 Xcode Ver: Xcode 9.3 Appc NPM: 4.2.13-2 Appc CLI: 7.0.3-master.34 Daemon Ver: 1.0.1 Ti CLI Ver: 5.1.0 Alloy Ver: 1.11.0 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 10 Devices: ⇨ google Nexus 5 --- Android 6.0.1 ⇨ google Nexus 6P --- Android 8.0.0
Awesome! BTW, what "nativeTableViewReference.setModelDirty()" is supposed to do? Thanks!
The
setModelDirty()
flags that the data for the TableView has changed and the UI needs to be updated via Android's "adapter" pattern. It's an optimization. The issue was that there was 1 spot in the code where we forgot to flag that the TableView needs updating after our last refactoring of the code. Sorry about the issue and thanks for reporting it.