package net.ktnx.mobileledger.ui.account_summary;
import android.content.res.Resources;
-import android.os.AsyncTask;
-import android.os.Handler;
-import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import net.ktnx.mobileledger.R;
+import net.ktnx.mobileledger.dao.BaseDAO;
import net.ktnx.mobileledger.databinding.AccountListRowBinding;
import net.ktnx.mobileledger.databinding.AccountListSummaryRowBinding;
import net.ktnx.mobileledger.db.Account;
throw new IllegalStateException("Unexpected value: " + viewType);
}
- Logger.debug("acc-ui", "Creating " + result);
+// Logger.debug("acc-ui", "Creating " + result);
return result;
}
@Override
return (position == 0) ? ITEM_TYPE_HEADER : ITEM_TYPE_ACCOUNT;
}
public void setAccounts(List<AccountListItem> newList) {
- new Handler(Looper.getMainLooper()).post(() -> listDiffer.submitList(newList));
+ Misc.onMainThread(() -> listDiffer.submitList(newList));
}
static class Change {
static final int NAME = 1;
@Override
public void bind(AccountListItem item, @Nullable List<Object> payloads) {
Resources r = itemView.getResources();
- Logger.debug("acc", itemView.getContext()
- .toString());
+// Logger.debug("acc", itemView.getContext()
+// .toString());
((AccountListItem.Header) item).getText()
.observe((LifecycleOwner) itemView.getContext(),
b.lastUpdateText::setText);
return;
debug("accounts", "Account expander clicked");
- AsyncTask.execute(() -> {
+ BaseDAO.runAsync(() -> {
Account dbo = account.toDBO();
dbo.setExpanded(!dbo.isExpanded());
Logger.debug("accounts",
@NotNull
private LedgerAccount getAccount() {
return listDiffer.getCurrentList()
- .get(getAdapterPosition())
+ .get(getBindingAdapterPosition())
.getAccount();
}
private void toggleAmountsExpanded() {
b.accountRowAmountsExpanderContainer.setVisibility(View.VISIBLE);
}
- AsyncTask.execute(() -> {
+ BaseDAO.runAsync(() -> {
Account dbo = account.toDBO();
DB.get()
.getAccountDAO()
changes.add((Change) p);
}
}
- debug("accounts",
- String.format(Locale.US, "Binding to '%s' to %s", acc.getName(), this));
+// debug("accounts",
+// String.format(Locale.US, "Binding '%s' to %s", acc.getName(), this));
Resources rm = b.getRoot()
.getContext()
if (changes.has(Change.LEVEL)) {
ConstraintLayout.LayoutParams lp =
- (ConstraintLayout.LayoutParams) b.accountNameLayout.getLayoutParams();
+ (ConstraintLayout.LayoutParams) b.flowWrapper.getLayoutParams();
lp.setMarginStart(
acc.getLevel() * rm.getDimensionPixelSize(R.dimen.thumb_row_height) / 3);
}
if (changes.has(Change.EXPANDED)) {
int wantedRotation = acc.isExpanded() ? 0 : 180;
if (b.accountExpanderContainer.getRotation() != wantedRotation) {
- Logger.debug("acc-ui",
- String.format(Locale.ROOT, "Rotating %s to %d", acc.getName(),
- wantedRotation));
+// Logger.debug("acc-ui",
+// String.format(Locale.ROOT, "Rotating %s to %d", acc.getName(),
+// wantedRotation));
b.accountExpanderContainer.animate()
.rotation(wantedRotation);
}