]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java
migrate to surrogate IDs for all database objects
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / new_transaction / NewTransactionModel.java
index 9539476d77f063e3e7239e95591831b7a64c4052..641a9b7b8686271f78e8b65f444755dcb77ed456 100644 (file)
@@ -260,6 +260,7 @@ public class NewTransactionModel extends ViewModel {
         if (Misc.emptyIsNull(transactionComment) != null)
             head.setComment(transactionComment);
 
+        Item.resetIdDispenser();
         List<Item> newItems = new ArrayList<>();
 
         newItems.add(head);
@@ -299,7 +300,7 @@ public class NewTransactionModel extends ViewModel {
                   newItems.add(accRow);
               }
 
-              new Handler(Looper.getMainLooper()).post(() -> setItems(newItems));
+              new Handler(Looper.getMainLooper()).post(() -> replaceItems(newItems));
           });
     }
     private int extractIntFromMatches(MatchResult m, Integer group, Integer literal) {
@@ -460,15 +461,15 @@ public class NewTransactionModel extends ViewModel {
 
         return tr;
     }
-    void loadTransactionIntoModel(String profileUUID, int transactionId) {
+    void loadTransactionIntoModel(long profileId, int transactionId) {
         List<Item> newList = new ArrayList<>();
         Item.resetIdDispenser();
         LedgerTransaction tr;
-        MobileLedgerProfile profile = Data.getProfile(profileUUID);
+        MobileLedgerProfile profile = Data.getProfile(profileId);
         if (profile == null)
             throw new RuntimeException(String.format(
                     "Unable to find profile %s, which is supposed to contain transaction %d",
-                    profileUUID, transactionId));
+                    profileId, transactionId));
 
         tr = profile.loadTransaction(transactionId);
         TransactionHead head = new TransactionHead(tr.getDescription());