From af34162e6868e8fd305e2b2c6037a7be7bf9936b Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Tue, 9 Mar 2021 22:18:56 +0200 Subject: [PATCH] fix flicker introduced with unique item Id 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. --- .../mobileledger/ui/new_transaction/NewTransactionModel.java | 5 +++++ 1 file changed, 5 insertions(+) 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 23a4ef73..4ed8a65d 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 @@ -170,6 +170,7 @@ public class NewTransactionModel extends ViewModel { void reset() { Logger.debug("new-trans", "Resetting model"); List list = new ArrayList<>(); + Item.resetIdDispenser(); 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 newList = new ArrayList<>(); + Item.resetIdDispenser(); 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); } + private static void resetIdDispenser() { + idDispenser = 0; + } public int getId() { return id; } -- 2.39.2