Skip to content

Commit c76535a

Browse files
m1gahansemannn
authored andcommitted
fix(android): reduce tableView updates (#13526)
1 parent 5d07f5c commit c76535a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

android/modules/ui/src/java/ti/modules/titanium/ui/TableViewProxy.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ static public TableViewSectionProxy processSection(Object obj)
128128
*/
129129
@Kroll.method
130130
public void appendRow(Object rows, @Kroll.argument(optional = true) KrollDict animation)
131+
{
132+
appendRowInternal(rows, animation, false);
133+
}
134+
135+
private void appendRowInternal(Object rows, KrollDict animation, boolean internalUpdate)
131136
{
132137
final List<TableViewRowProxy> rowList = new ArrayList<>();
133138

@@ -190,7 +195,11 @@ public void appendRow(Object rows, @Kroll.argument(optional = true) KrollDict an
190195

191196
// Allow updating rows after iteration.
192197
shouldUpdate = true;
193-
update();
198+
199+
// don't update when coming from setData loop
200+
if (!internalUpdate) {
201+
update();
202+
}
194203
}
195204

196205
/**
@@ -508,7 +517,7 @@ public void setData(Object[] data)
508517
final TableViewRowProxy row = (TableViewRowProxy) d;
509518

510519
// Handle TableViewRow.
511-
appendRow(row, null);
520+
appendRowInternal(row, null, true);
512521

513522
} else if (d instanceof Object[]) {
514523
setData((Object[]) d);
@@ -519,7 +528,7 @@ public void setData(Object[] data)
519528

520529
// Handle TableViewRow dictionary.
521530
row.handleCreationDict(new KrollDict((HashMap) d));
522-
appendRow(row, null);
531+
appendRowInternal(row, null, true);
523532

524533
} else if (d instanceof TableViewSectionProxy) {
525534
final TableViewSectionProxy section = (TableViewSectionProxy) d;
@@ -531,7 +540,6 @@ public void setData(Object[] data)
531540

532541
// Allow updating rows after iteration.
533542
shouldUpdate = true;
534-
535543
update();
536544
}
537545

0 commit comments

Comments
 (0)