From: Damyan Ivanov Date: Wed, 5 May 2021 16:55:16 +0000 (+0300) Subject: fix a crash when applying more than one template via QR code X-Git-Tag: v0.18.0~2 X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=commitdiff_plain;h=4ab502e75190b212a0c01b66e4eae1f1eb402862 fix a crash when applying more than one template via QR code --- 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)); }); }