X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fasync%2FRetrieveTransactionsTask.java;h=14d700c2f28d1ef8eacd2def053b6957dce947a9;hb=0fbcabbed3b047c6f24be3def42f3ed2bb2928af;hp=20a8a20bef3ef59ccb776f91cb7863b6b571ac89;hpb=760d6de24d0c4035380c99440f5771ebf2ed96bf;p=mobile-ledger-staging.git
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 20a8a20b..14d700c2 100644
--- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java
+++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java
@@ -73,8 +73,11 @@ public class RetrieveTransactionsTask
private Pattern reAccountName = Pattern.compile("/register\\?q=inacct%3A([a-zA-Z0-9%]+)\"");
private Pattern reAccountValue = Pattern.compile(
"\\s*([-+]?[\\d.,]+)(?:\\s+(\\S+))?");
- public RetrieveTransactionsTask(WeakReference contextRef) {
+ private MobileLedgerProfile profile;
+ public RetrieveTransactionsTask(WeakReference contextRef,
+ MobileLedgerProfile profile) {
this.contextRef = contextRef;
+ this.profile = profile;
}
private static void L(String msg) {
//debug("transaction-parser", msg);
@@ -107,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;
@@ -249,7 +252,8 @@ public class RetrieveTransactionsTask
lastAccount.addAmount(val, currency);
for (LedgerAccount syn : syntheticAccounts.values()) {
syn.addAmount(val, currency);
- profile.storeAccountValue(db, syn.getName(), currency, val);
+ profile.storeAccountValue(db, syn.getName(), currency,
+ val);
}
}
@@ -393,7 +397,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();
@@ -481,7 +485,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;
@@ -589,11 +593,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) {