X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fasync%2FRetrieveTransactionsTask.java;h=9db9c9dfdce8426b0df7275c7246c6515026f08f;hp=8d98dc63c89e920ce1128df939f0ee014b33805b;hb=0fc2ddc465cd9b9314ae336e69535020a96a7fbc;hpb=23b8360d4f884bbdb20cc2de1825486ef42f37d6 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 8d98dc63..9db9c9df 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/RetrieveTransactionsTask.java @@ -21,7 +21,6 @@ import android.annotation.SuppressLint; import android.database.sqlite.SQLiteDatabase; import android.os.AsyncTask; import android.os.OperationCanceledException; -import android.util.Log; import net.ktnx.mobileledger.err.HTTPException; import net.ktnx.mobileledger.json.AccountListParser; @@ -70,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 contextRef; - private int error; // %3A is '=' 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); @@ -109,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; @@ -154,7 +155,7 @@ public class RetrieveTransactionsTask m = reComment.matcher(line); if (m.find()) { // TODO: comments are ignored for now - Log.v("transaction-parser", "Ignoring comment"); +// Log.v("transaction-parser", "Ignoring comment"); continue; } //L(String.format("State is %d", updating)); @@ -395,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(); @@ -483,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; @@ -591,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) {