checkTransactionSubmittable(newList);
setItemsWithoutSubmittableChecks(newList);
}
+ private void replaceItems(@NonNull List<Item> newList) {
+ renumberItems();
+
+ setItems(newList);
+ }
+ /**
+ * make old items replaceable in-place. makes the new values visually blend in
+ */
+ private void renumberItems() {
+ final List<Item> list = items.getValue();
+ if (list == null) {
+ return;
+ }
+
+ int id = 0;
+ for (Item item : list)
+ item.id = id++;
+ }
private void setItemsWithoutSubmittableChecks(@NonNull List<Item> list) {
final int cnt = list.size();
for (int i = 1; i < cnt - 1; i++) {
list.add(new TransactionAccount(""));
list.add(new TransactionAccount(""));
noteFocusChanged(0, FocusedElement.Description);
+ renumberItems();
isSubmittable.setValue(false);
setItemsWithoutSubmittableChecks(list);
}
static abstract class Item {
private static int idDispenser = 0;
- protected final int id;
+ protected int id;
private Item() {
if (this instanceof TransactionHead)
id = 0;