From: Damyan Ivanov Date: Tue, 9 Mar 2021 20:18:56 +0000 (+0200) Subject: fix flicker introduced with unique item Id X-Git-Tag: v0.17.0~5 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=af34162e6868e8fd305e2b2c6037a7be7bf9936b;p=mobile-ledger.git 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. --- 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; }