X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FNewTransactionActivity.java;h=5a5a352c821ac0b5cb8e0a1396ae9d5f3c236a69;hp=b7770dcc5310f2366ee9a0bb628392f989e8a42e;hb=7165b89c8ff2b9d8f69e02354197127ec27a4a47;hpb=83cac114e375728080194fb09758b49c50a8119b diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java index b7770dcc..5a5a352c 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java @@ -56,12 +56,12 @@ import net.ktnx.mobileledger.model.MobileLedgerProfile; import net.ktnx.mobileledger.ui.DatePickerFragment; import net.ktnx.mobileledger.ui.OnSwipeTouchListener; import net.ktnx.mobileledger.utils.Globals; +import net.ktnx.mobileledger.utils.LockHolder; import net.ktnx.mobileledger.utils.MLDB; import java.text.ParseException; import java.util.ArrayList; import java.util.Date; -import java.util.List; import java.util.Locale; import java.util.Objects; @@ -492,20 +492,22 @@ public class NewTransactionActivity extends ProfileThemedActivity String profileUUID = c.getString(0); int transactionId = c.getInt(1); LedgerTransaction tr; + try(LockHolder lh = Data.profiles.lockForReading()) { MobileLedgerProfile profile = null; for (int i = 0; i < Data.profiles.size(); i++) { MobileLedgerProfile p = Data.profiles.get(i); if (p.getUuid().equals(profileUUID)) { profile = p; break; + } } - } if (profile == null) throw new RuntimeException(String.format( "Unable to find profile %s, which is supposed to contain " + "transaction %d with description %s", profileUUID, transactionId, description)); tr = profile.loadTransaction(transactionId); + } int i = 0; table = findViewById(R.id.new_transaction_accounts_table); ArrayList accounts = tr.getAccounts();