]> git.ktnx.net Git - mobile-ledger.git/commitdiff
profile should not be null when requesting transaction retrieval
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 3 May 2019 16:07:36 +0000 (19:07 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 3 May 2019 16:11:45 +0000 (19:11 +0300)
app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java
app/src/main/java/net/ktnx/mobileledger/model/Data.java

index 465977b32e2c97e16235b49ffffaf2c55cbed201..c1406d250d1d9462931858eddaffb63a55ee0ae0 100644 (file)
@@ -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
             "<span class=\"[^\"]*\\bamount\\b[^\"]*\">\\s*([-+]?[\\d.,]+)(?:\\s+(\\S+))?</span>");
     private MobileLedgerProfile profile;
     public RetrieveTransactionsTask(WeakReference<MainActivity> contextRef,
-                                    MobileLedgerProfile profile) {
+                                    @NonNull MobileLedgerProfile profile) {
         this.contextRef = contextRef;
         this.profile = profile;
     }
index 7687d237f2279da693d04d27a2448b0e02139b8d..6415384766f848c4253b50579d4f6f0ac1c13016 100644 (file)
@@ -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");