]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java
migrate a bunch of globals to LiveData
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / async / RetrieveTransactionsTask.java
index 207793bbaa7fdc176968cfd5f5d05b2addd1b559..9db9c9dfdce8426b0df7275c7246c6515026f08f 100644 (file)
@@ -69,13 +69,15 @@ public class RetrieveTransactionsTask
             Pattern.compile("^\\s+(\\S[\\S\\s]+\\S)\\s\\s+([-+]?\\d[\\d,.]*)(?:\\s+(\\S+)$)?");
     private static final Pattern reEnd = Pattern.compile("\\bid=\"addmodal\"");
     private WeakReference<MainActivity> contextRef;
-    private int error;
     // %3A is '='
     private Pattern reAccountName = Pattern.compile("/register\\?q=inacct%3A([a-zA-Z0-9%]+)\"");
     private Pattern reAccountValue = Pattern.compile(
             "<span class=\"[^\"]*\\bamount\\b[^\"]*\">\\s*([-+]?[\\d.,]+)(?:\\s+(\\S+))?</span>");
-    public RetrieveTransactionsTask(WeakReference<MainActivity> contextRef) {
+    private MobileLedgerProfile profile;
+    public RetrieveTransactionsTask(WeakReference<MainActivity> contextRef,
+                                    MobileLedgerProfile profile) {
         this.contextRef = contextRef;
+        this.profile = profile;
     }
     private static void L(String msg) {
         //debug("transaction-parser", msg);
@@ -108,7 +110,7 @@ public class RetrieveTransactionsTask
         if (context == null) return;
         context.onRetrieveDone(null);
     }
-    private String retrieveTransactionListLegacy(MobileLedgerProfile profile)
+    private String retrieveTransactionListLegacy()
             throws IOException, ParseException, HTTPException {
         Progress progress = new Progress();
         int maxTransactionId = Progress.INDETERMINATE;
@@ -394,7 +396,7 @@ public class RetrieveTransactionsTask
                 new String[]{profile.getUuid()});
         db.execSQL("update accounts set keep=0 where profile=?;", new String[]{profile.getUuid()});
     }
-    private boolean retrieveAccountList(MobileLedgerProfile profile)
+    private boolean retrieveAccountList()
             throws IOException, HTTPException {
         Progress progress = new Progress();
 
@@ -482,7 +484,7 @@ public class RetrieveTransactionsTask
 
         return true;
     }
-    private boolean retrieveTransactionList(MobileLedgerProfile profile)
+    private boolean retrieveTransactionList()
             throws IOException, ParseException, HTTPException {
         Progress progress = new Progress();
         int maxTransactionId = Progress.INDETERMINATE;
@@ -590,11 +592,10 @@ public class RetrieveTransactionsTask
     @SuppressLint("DefaultLocale")
     @Override
     protected String doInBackground(Void... params) {
-        MobileLedgerProfile profile = Data.profile.get();
         Data.backgroundTaskStarted();
         try {
-            if (!retrieveAccountList(profile) || !retrieveTransactionList(profile))
-                return retrieveTransactionListLegacy(profile);
+            if (!retrieveAccountList() || !retrieveTransactionList())
+                return retrieveTransactionListLegacy();
             return null;
         }
         catch (MalformedURLException e) {