import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
-import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RetrieveTransactionsTask extends
AsyncTask<RetrieveTransactionsTask.Params, RetrieveTransactionsTask.Progress, Void> {
+ public static final int MATCHING_TRANSACTIONS_LIMIT = 50;
private static final Pattern transactionStartPattern = Pattern.compile("<tr class=\"title\" " +
"id=\"transaction-(\\d+)\"><td class=\"date\"[^\\\"]*>([\\d.-]+)</td>");
private static final Pattern transactionDescriptionPattern =
Progress progress = new Progress();
int maxTransactionId = Progress.INDETERMINATE;
success = false;
- List<LedgerAccount> accountList = new ArrayList<>();
+ ArrayList<LedgerAccount> accountList = new ArrayList<>();
LedgerAccount lastAccount = null;
Data.backgroundTaskCount.incrementAndGet();
try {
"=?", new Integer[]{transaction.getId()});
matchedTransactionsCount++;
- if (matchedTransactionsCount == 100) {
+ if (matchedTransactionsCount ==
+ MATCHING_TRANSACTIONS_LIMIT)
+ {
db.execSQL("UPDATE transactions SET keep=1 WHERE " +
"id < ?",
new Integer[]{transaction.getId()});
String.format("Unknown parser updating %s", state.name()));
}
}
- if (!isCancelled()) {
- db.execSQL("DELETE FROM transactions WHERE keep = 0");
- db.setTransactionSuccessful();
- }
+
+ throwIfCancelled();
+
+ db.execSQL("DELETE FROM transactions WHERE keep = 0");
+ db.setTransactionSuccessful();
}
finally {
db.endTransaction();