+ private MainActivity getContext() {
+ return contextRef.get();
+ }
+ private void addAccount(SQLiteDatabase db, String name) {
+ do {
+ LedgerAccount acc = new LedgerAccount(name);
+ db.execSQL("update accounts set level = ?, keep = 1 where name = ?",
+ new Object[]{acc.getLevel(), name});
+ db.execSQL("insert into accounts(name, name_upper, parent_name, level) select ?,?," +
+ "?,? " + "where (select changes() = 0)",
+ new Object[]{name, name.toUpperCase(), acc.getParentName(), acc.getLevel()});
+ name = acc.getParentName();
+ } while (name != null);
+ }
+ private void throwIfCancelled() {
+ if (isCancelled()) throw new OperationCanceledException(null);
+ }
+
+ private enum ParserState {
+ EXPECTING_ACCOUNT, EXPECTING_ACCOUNT_AMOUNT, EXPECTING_JOURNAL, EXPECTING_TRANSACTION,
+ EXPECTING_TRANSACTION_DESCRIPTION, EXPECTING_TRANSACTION_DETAILS
+ }
+
+ public static class Params {
+ private SharedPreferences backendPref;
+
+ public Params(SharedPreferences backendPref) {
+ this.backendPref = backendPref;
+ }
+ SharedPreferences getBackendPref() {
+ return backendPref;
+ }
+ }
+
+ public class Progress {
+ public static final int INDETERMINATE = -1;
+ private int progress;
+ private int total;
+ Progress() {
+ this(INDETERMINATE, INDETERMINATE);
+ }
+ Progress(int progress, int total) {
+ this.progress = progress;
+ this.total = total;
+ }
+ public int getProgress() {
+ return progress;
+ }
+ protected void setProgress(int progress) {
+ this.progress = progress;
+ }
+ public int getTotal() {
+ return total;
+ }
+ protected void setTotal(int total) {
+ this.total = total;
+ }