]> git.ktnx.net Git - mobile-ledger-staging.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/model/MobileLedgerProfile.java
fix merging of account lists so that changes are detected
[mobile-ledger-staging.git] / app / src / main / java / net / ktnx / mobileledger / model / MobileLedgerProfile.java
index 6b847ec103c1cb91aa5a2ea34e0a155632dae751..7ae6b5a91b8d96a9c196fc52e362bee2d7e7e6bf 100644 (file)
@@ -214,10 +214,12 @@ public final class MobileLedgerProfile {
                 continue;
             }
 
-            // two items with same account names; merge UI-controlled fields
-            oldAcc.setExpanded(newAcc.isExpanded());
-            oldAcc.setAmountsExpanded(newAcc.amountsExpanded());
-            merged.add(oldAcc);
+            // two items with same account names; forward-merge UI-controlled fields
+            // it is important that the result list contains a new LedgerAccount instance
+            // so that the change is propagated to the UI
+            newAcc.setExpanded(oldAcc.isExpanded());
+            newAcc.setAmountsExpanded(oldAcc.amountsExpanded());
+            merged.add(newAcc);
         }
 
         return merged;