public class AccountSummaryAdapter
extends RecyclerView.Adapter<AccountSummaryAdapter.LedgerRowHolder> {
public static final int AMOUNT_LIMIT = 3;
- private MobileLedgerProfile profile;
private AsyncListDiffer<LedgerAccount> listDiffer;
AccountSummaryAdapter() {
listDiffer = new AsyncListDiffer<>(this, new DiffUtil.ItemCallback<LedgerAccount>() {
return listDiffer.getCurrentList()
.size();
}
- public void setAccounts(MobileLedgerProfile profile, List<LedgerAccount> newList) {
- this.profile = profile;
+ public void setAccounts(List<LedgerAccount> newList) {
listDiffer.submitList(newList);
}
static class LedgerRowHolder extends RecyclerView.ViewHolder {
MobileLedgerProfile profile = Data.getProfile();
profile.getDisplayedAccounts()
- .observe(getViewLifecycleOwner(),
- (accounts) -> onAccountsChanged(profile, accounts));
+ .observe(getViewLifecycleOwner(), this::onAccountsChanged);
}
- private void onAccountsChanged(MobileLedgerProfile profile, List<LedgerAccount> accounts) {
+ private void onAccountsChanged(List<LedgerAccount> accounts) {
Logger.debug("async-acc",
String.format(Locale.US, "fragment: got new account list (%d items)",
accounts.size()));
- modelAdapter.setAccounts(profile, accounts);
+ modelAdapter.setAccounts(accounts);
}
}