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;
import net.ktnx.mobileledger.model.MobileLedgerProfile;
import net.ktnx.mobileledger.ui.activity.MainActivity;
import net.ktnx.mobileledger.utils.Locker;
+import net.ktnx.mobileledger.utils.Logger;
import org.jetbrains.annotations.NotNull;
import java.util.List;
+import java.util.Locale;
import static net.ktnx.mobileledger.utils.Logger.debug;
return true;
}
public void bindToAccount(LedgerAccount acc) {
+ Logger.debug("accounts", String.format(Locale.US, "Binding to '%s'", acc.getName()));
Context ctx = row.getContext();
Resources rm = ctx.getResources();
mAccount = acc;
}
private void aTest(LedgerAccount[] oldList, LedgerAccount[] newList,
LedgerAccount[] expectedResult) {
- List<LedgerAccount> result = MobileLedgerProfile.mergeAccountLists(listFromArray(oldList),
- listFromArray(newList));
+ List<LedgerAccount> result =
+ MobileLedgerProfile.mergeAccountListsFromWeb(listFromArray(oldList),
+ listFromArray(newList));
assertArrayEquals(expectedResult, result.toArray());
}
private void negTest(LedgerAccount[] oldList, LedgerAccount[] newList,
LedgerAccount[] expectedResult) {
- List<LedgerAccount> result = MobileLedgerProfile.mergeAccountLists(listFromArray(oldList),
- listFromArray(newList));
+ List<LedgerAccount> result =
+ MobileLedgerProfile.mergeAccountListsFromWeb(listFromArray(oldList),
+ listFromArray(newList));
assertThrows(ArrayComparisonFailure.class,
() -> assertArrayEquals(expectedResult, result.toArray()));
}
LedgerAccount acc1b = new LedgerAccount(null, "Acc1", null);
acc1b.setExpanded(true);
acc1b.setAmountsExpanded(true);
- List<LedgerAccount> merged =
- MobileLedgerProfile.mergeAccountLists(listFromArray(new LedgerAccount[]{acc1a}),
- listFromArray(new LedgerAccount[]{acc1b}));
+ List<LedgerAccount> merged = MobileLedgerProfile.mergeAccountListsFromWeb(
+ listFromArray(new LedgerAccount[]{acc1a}),
+ listFromArray(new LedgerAccount[]{acc1b}));
assertArrayEquals(new LedgerAccount[]{acc1b}, merged.toArray());
assertSame(merged.get(0), acc1a);
// restore original values, modified by the merge