Skip to content

Commit

Permalink
fix(android): reduce tableView updates (#13526)
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga authored and hansemannn committed Aug 24, 2023
1 parent 5d07f5c commit c76535a
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ static public TableViewSectionProxy processSection(Object obj)
*/
@Kroll.method
public void appendRow(Object rows, @Kroll.argument(optional = true) KrollDict animation)
{
appendRowInternal(rows, animation, false);
}

private void appendRowInternal(Object rows, KrollDict animation, boolean internalUpdate)
{
final List<TableViewRowProxy> rowList = new ArrayList<>();

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

// Allow updating rows after iteration.
shouldUpdate = true;
update();

// don't update when coming from setData loop
if (!internalUpdate) {
update();
}
}

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

// Handle TableViewRow.
appendRow(row, null);
appendRowInternal(row, null, true);

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

// Handle TableViewRow dictionary.
row.handleCreationDict(new KrollDict((HashMap) d));
appendRow(row, null);
appendRowInternal(row, null, true);

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

// Allow updating rows after iteration.
shouldUpdate = true;

update();
}

Expand Down

0 comments on commit c76535a

Please sign in to comment.