protected WeakReference<MainActivity> contextRef;
protected int error;
// %3A is '='
+ private Pattern ledger_title_re = Pattern.compile("<h1>([^<]+)</h1>");
Pattern account_name_re = Pattern.compile("/register\\?q=inacct%3A([a-zA-Z0-9%]+)\"");
Pattern account_value_re = Pattern.compile(
"<span class=\"[^\"]*\\bamount\\b[^\"]*\">\\s*([-+]?[\\d.,]+)(?:\\s+(\\S+))?</span>");
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;");
state = ParserState.EXPECTING_ACCOUNT_AMOUNT;
L("→ expecting account amount");
}
+ else if (ledgerTitle == null) {
+ m = ledger_title_re.matcher(line);
+ if (m.find()) {
+ ledgerTitle = m.group(1);
+ Data.ledgerTitle.set(ledgerTitle);
+ }
+ }
break;
case EXPECTING_ACCOUNT_AMOUNT:
public static ObservableValue<List<String>> descriptions = new ObservableValue<>();
public static ObservableAtomicInteger backgroundTaskCount = new ObservableAtomicInteger(0);
public static ObservableValue<Date> lastUpdateDate = new ObservableValue<>();
+ public static ObservableValue<String> ledgerTitle = new ObservableValue<>();
}
scheduleTransactionListRetrieval();
}
+
+ Data.ledgerTitle.addObserver(new Observer() {
+ @Override
+ public void update(Observable o, Object arg) {
+ runOnUiThread(() -> {
+ String title = Data.ledgerTitle.get();
+ if (title == null)
+ toolbar.setSubtitle("");
+ else
+ toolbar.setSubtitle(title);
+ });
+ }
+ });
}
public void fab_new_transaction_clicked(View view) {
Intent intent = new Intent(this, NewTransactionActivity.class);