From 37ceda689838d455a04e2e0284a679b6b6690013 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 3 May 2019 19:07:36 +0300 Subject: [PATCH] profile should not be null when requesting transaction retrieval --- .../net/ktnx/mobileledger/async/RetrieveTransactionsTask.java | 4 +++- app/src/main/java/net/ktnx/mobileledger/model/Data.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) 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"); -- 2.39.5