]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix a crash when applying more than one template via QR code
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 5 May 2021 16:55:16 +0000 (19:55 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Wed, 5 May 2021 16:55:16 +0000 (19:55 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java

index 311226dacd6ec85504e562bc30bab73bf1697e63..1d0eedf58ae5e3ed1a2f84a8bc3d4b6fce75dd8d 100644 (file)
@@ -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<Item> list = items.getValue();
+        renumberItems(items.getValue());
+    }
+    private void renumberItems(List<Item> 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<Item> newItems = new ArrayList<>();
 
         newItems.add(head);
@@ -302,6 +303,7 @@ public class NewTransactionModel extends ViewModel {
                   newItems.add(accRow);
               }
 
+              renumberItems(newItems);
               Misc.onMainThread(() -> replaceItems(newItems));
           });
     }