- // make sure we use the same object as the one in the allAccounts list
- MobileLedgerProfile profile = mAccount.getProfile();
- if (profile == null) {
- return;
- }
- try (Locker ignored = profile.lockAccountsForWriting()) {
- LedgerAccount realAccount = profile.locateAccount(mAccount.getName());
- if (realAccount == null)
- return;
-
- mAccount = realAccount;
- mAccount.toggleExpanded();
- }
- expanderContainer.animate()
- .rotation(mAccount.isExpanded() ? 0 : 180);
- profile.updateDisplayedAccounts();
-
- DbOpQueue.add("update accounts set expanded=? where name=? and profile=?",
- new Object[]{mAccount.isExpanded(), mAccount.getName(), profile.getUuid()
- });
-
+ AsyncTask.execute(() -> {
+ Account dbo = account.toDBO();
+ dbo.setExpanded(!dbo.isExpanded());
+ Logger.debug("accounts",
+ String.format(Locale.ROOT, "%s (%d) → %s", account.getName(), dbo.getId(),
+ dbo.isExpanded() ? "expanded" : "collapsed"));
+ DB.get()
+ .getAccountDAO()
+ .updateSync(dbo);
+ });
+ }
+ @NotNull
+ private LedgerAccount getAccount() {
+ return listDiffer.getCurrentList()
+ .get(getAdapterPosition())
+ .getAccount();