From: Damyan Ivanov Date: Fri, 3 May 2019 16:07:36 +0000 (+0300) Subject: profile should not be null when requesting transaction retrieval X-Git-Tag: v0.10.0~38 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=37ceda689838d455a04e2e0284a679b6b6690013;p=mobile-ledger.git profile should not be null when requesting transaction retrieval --- diff --git a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java index 465977b3..c1406d25 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -54,6 +54,8 @@ import java.util.Stack; import java.util.regex.Matcher; import java.util.regex.Pattern; +import androidx.annotation.NonNull; + import static net.ktnx.mobileledger.utils.Logger.debug; @@ -75,7 +77,7 @@ public class RetrieveTransactionsTask "\\s*([-+]?[\\d.,]+)(?:\\s+(\\S+))?"); private MobileLedgerProfile profile; public RetrieveTransactionsTask(WeakReference contextRef, - MobileLedgerProfile profile) { + @NonNull MobileLedgerProfile profile) { this.contextRef = contextRef; this.profile = profile; } diff --git a/app/src/main/java/net/ktnx/mobileledger/model/Data.java b/app/src/main/java/net/ktnx/mobileledger/model/Data.java index 7687d237..64153847 100644 --- a/app/src/main/java/net/ktnx/mobileledger/model/Data.java +++ b/app/src/main/java/net/ktnx/mobileledger/model/Data.java @@ -136,6 +136,9 @@ public final class Data { Logger.debug("db", "Ignoring request for transaction retrieval - already active"); return; } + MobileLedgerProfile pr = profile.getValue(); + if (pr == null) throw new IllegalStateException("No current profile"); + retrieveTransactionsTask = new RetrieveTransactionsTask(new WeakReference<>(activity), profile.getValue()); Logger.debug("db", "Created a background transaction retrieval task");