]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix flicker introduced with unique item Id
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 9 Mar 2021 20:18:56 +0000 (22:18 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Tue, 9 Mar 2021 20:18:56 +0000 (22:18 +0200)
when items get unique id every time, resetting the model causes new
IDs to be assigned, making the adapter consider old items gone and new
items added. this sounds OK, but the visual effect is that everything
disappears and then reappears, causing flicker.

app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java

index 23a4ef73cafcd6eddefcfa9ff59b1e832e5187ec..4ed8a65d6298c118c208e6dbfbb5a4ec2b8b459f 100644 (file)
@@ -170,6 +170,7 @@ public class NewTransactionModel extends ViewModel {
     void reset() {
         Logger.debug("new-trans", "Resetting model");
         List<Item> list = new ArrayList<>();
     void reset() {
         Logger.debug("new-trans", "Resetting model");
         List<Item> list = new ArrayList<>();
+        Item.resetIdDispenser();
         list.add(new TransactionHead(""));
         list.add(new TransactionAccount(""));
         list.add(new TransactionAccount(""));
         list.add(new TransactionHead(""));
         list.add(new TransactionAccount(""));
         list.add(new TransactionAccount(""));
@@ -442,6 +443,7 @@ public class NewTransactionModel extends ViewModel {
     }
     void loadTransactionIntoModel(String profileUUID, int transactionId) {
         List<Item> newList = new ArrayList<>();
     }
     void loadTransactionIntoModel(String profileUUID, int transactionId) {
         List<Item> newList = new ArrayList<>();
+        Item.resetIdDispenser();
         LedgerTransaction tr;
         MobileLedgerProfile profile = Data.getProfile(profileUUID);
         if (profile == null)
         LedgerTransaction tr;
         MobileLedgerProfile profile = Data.getProfile(profileUUID);
         if (profile == null)
@@ -876,6 +878,9 @@ public class NewTransactionModel extends ViewModel {
                 return new TransactionAccount((TransactionAccount) origin);
             throw new RuntimeException("Don't know how to handle " + origin);
         }
                 return new TransactionAccount((TransactionAccount) origin);
             throw new RuntimeException("Don't know how to handle " + origin);
         }
+        private static void resetIdDispenser() {
+            idDispenser = 0;
+        }
         public int getId() {
             return id;
         }
         public int getId() {
             return id;
         }