X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Fnew_transaction%2FNewTransactionModel.java;h=2bcf82fb8d46ce3d54d193436087eaf4bba83ba4;hb=916547239190f7daf921f2066593637cfca877fc;hp=7ff061a6ea30994bb15437d3297ee4683334f795;hpb=5df10dc0b58df4d4be4e9ab34f1e0f477ca46766;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java index 7ff061a6..2bcf82fb 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionModel.java @@ -18,8 +18,6 @@ package net.ktnx.mobileledger.ui.new_transaction; import android.annotation.SuppressLint; -import android.os.Handler; -import android.os.Looper; import android.text.TextUtils; import androidx.annotation.NonNull; @@ -301,7 +299,7 @@ public class NewTransactionModel extends ViewModel { newItems.add(accRow); } - new Handler(Looper.getMainLooper()).post(() -> replaceItems(newItems)); + Misc.onMainThread(() -> replaceItems(newItems)); }); } private int extractIntFromMatches(MatchResult m, Integer group, Integer literal) { @@ -428,7 +426,6 @@ public class NewTransactionModel extends ViewModel { List list = Objects.requireNonNull(items.getValue()); TransactionHead head = list.get(0) .toTransactionHead(); - SimpleDate date = head.getDate(); LedgerTransaction tr = head.asLedgerTransaction(); tr.setComment(head.getComment()); @@ -523,7 +520,7 @@ public class NewTransactionModel extends ViewModel { moveItemLast(newList, singlePositiveIndex); } - new Handler(Looper.getMainLooper()).post(() -> { + Misc.onMainThread(() -> { setItems(newList); noteFocusChanged(1, FocusedElement.Amount); }); @@ -1029,7 +1026,8 @@ public class NewTransactionModel extends ViewModel { return ItemType.generalData; } public LedgerTransaction asLedgerTransaction() { - return new LedgerTransaction(0, date, description, Data.getProfile()); + return new LedgerTransaction(0, (date == null) ? SimpleDate.today() : date, description, + Data.getProfile()); } public boolean equalContents(TransactionHead other) { if (other == null)