- Data.backgroundTaskCount.incrementAndGet();
- try {
- HttpURLConnection http = NetworkUtil.prepare_connection("journal");
- http.setAllowUserInteraction(false);
- publishProgress(progress);
- MainActivity ctx = getContext();
- if (ctx == null) return null;
- try (SQLiteDatabase db = MLDB.getWritableDatabase()) {
- try (InputStream resp = http.getInputStream()) {
- if (http.getResponseCode() != 200) throw new IOException(
- String.format("HTTP error %d", http.getResponseCode()));
- db.beginTransaction();
- try {
- String ledgerTitle = null;
-
- db.execSQL("UPDATE transactions set keep=0");
- db.execSQL("update account_values set keep=0;");
- db.execSQL("update accounts set keep=0;");
-
- ParserState state = ParserState.EXPECTING_ACCOUNT;
- String line;
- BufferedReader buf =
- new BufferedReader(new InputStreamReader(resp, "UTF-8"));
-
- int processedTransactionCount = 0;
- int transactionId = 0;
- int matchedTransactionsCount = 0;
- LedgerTransaction transaction = null;
- LINES:
- while ((line = buf.readLine()) != null) {
- throwIfCancelled();
- Matcher m;
- m = commentPattern.matcher(line);
- if (m.find()) {
- // TODO: comments are ignored for now
- Log.v("transaction-parser", "Ignoring comment");
- continue;
- }
- //L(String.format("State is %d", updating));
- switch (state) {
- case EXPECTING_ACCOUNT:
- if (line.equals("<h2>General Journal</h2>")) {
- state = ParserState.EXPECTING_TRANSACTION;
- L("→ expecting transaction");
- Data.accounts.set(accountList);
- continue;
- }
- m = account_name_re.matcher(line);
- if (m.find()) {
- String acct_encoded = m.group(1);
- String acct_name = URLDecoder.decode(acct_encoded, "UTF-8");
- acct_name = acct_name.replace("\"", "");
- L(String.format("found account: %s", acct_name));
+ boolean onlyStarred = Data.optShowOnlyStarred.get();
+
+ HttpURLConnection http = NetworkUtil.prepareConnection(profile, "journal");
+ http.setAllowUserInteraction(false);
+ publishProgress(progress);
+ try (SQLiteDatabase db = MLDB.getWritableDatabase()) {
+ try (InputStream resp = http.getInputStream()) {
+ if (http.getResponseCode() != 200)
+ throw new IOException(String.format("HTTP error %d", http.getResponseCode()));
+ db.beginTransaction();
+ try {
+ prepareDbForRetrieval(db, profile);
+
+ int matchedTransactionsCount = 0;