From 4ab502e75190b212a0c01b66e4eae1f1eb402862 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Wed, 5 May 2021 19:55:16 +0300 Subject: [PATCH] fix a crash when applying more than one template via QR code --- .../ui/new_transaction/NewTransactionModel.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java index 311226da..1d0eedf5 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java @@ -101,7 +101,9 @@ public class NewTransactionModel extends ViewModel { * make old items replaceable in-place. makes the new values visually blend in */ private void renumberItems() { - final List list = items.getValue(); + renumberItems(items.getValue()); + } + private void renumberItems(List list) { if (list == null) { return; } @@ -260,7 +262,6 @@ public class NewTransactionModel extends ViewModel { if (Misc.emptyIsNull(transactionComment) != null) head.setComment(transactionComment); - Item.resetIdDispenser(); List newItems = new ArrayList<>(); newItems.add(head); @@ -302,6 +303,7 @@ public class NewTransactionModel extends ViewModel { newItems.add(accRow); } + renumberItems(newItems); Misc.onMainThread(() -> replaceItems(newItems)); }); } -- 2.39.5