private void init(@Nullable SQLiteDatabase db) {
    if (db == null) {
      mAccountsDbAdapter = AccountsDbAdapter.getInstance();
      mTransactionsDbAdapter = TransactionsDbAdapter.getInstance();
      mScheduledActionsDbAdapter = ScheduledActionDbAdapter.getInstance();
      mCommoditiesDbAdapter = CommoditiesDbAdapter.getInstance();
      mPricesDbAdapter = PricesDbAdapter.getInstance();
    } else {
      mTransactionsDbAdapter = new TransactionsDbAdapter(db, new SplitsDbAdapter(db));
      mAccountsDbAdapter = new AccountsDbAdapter(db, mTransactionsDbAdapter);
      mScheduledActionsDbAdapter = new ScheduledActionDbAdapter(db);
      mCommoditiesDbAdapter = new CommoditiesDbAdapter(db);
      mPricesDbAdapter = new PricesDbAdapter(db);
    }

    mContent = new StringBuilder();

    mAccountList = new ArrayList<>();
    mAccountMap = new HashMap<>();
    mTransactionList = new ArrayList<>();
    mScheduledActionsList = new ArrayList<>();

    mTemplatAccountList = new ArrayList<>();
    mTemplateTransactions = new ArrayList<>();
    mTemplateAccountToTransactionMap = new HashMap<>();

    mAutoBalanceSplits = new ArrayList<>();

    mPriceList = new ArrayList<>();
  }
示例#2
0
  @Before
  public void setUp() throws Exception {

    mSplitsDbAdapter = SplitsDbAdapter.getInstance();
    mTransactionsDbAdapter = TransactionsDbAdapter.getInstance();
    mAccountsDbAdapter = AccountsDbAdapter.getInstance();
  }
  @Before
  public void setUp() throws Exception {
    mSplitsDbAdapter = SplitsDbAdapter.getInstance();
    mTransactionsDbAdapter = TransactionsDbAdapter.getInstance();
    mAccountsDbAdapter = AccountsDbAdapter.getInstance();

    alphaAccount = new Account(ALPHA_ACCOUNT_NAME);
    bravoAccount = new Account(BRAVO_ACCOUNT_NAME);

    mAccountsDbAdapter.addRecord(bravoAccount);
    mAccountsDbAdapter.addRecord(alphaAccount);

    mTestSplit = new Split(new Money(BigDecimal.TEN, DEFAULT_CURRENCY), alphaAccount.getUID());
  }
示例#4
0
  /** Extracts arguments passed to the view and initializes necessary adapters and cursors */
  private void initArgs() {
    mAccountsDbAdapter = AccountsDbAdapter.getInstance();

    Bundle args = getArguments();
    mAccountUID = ((FormActivity) getActivity()).getCurrentAccountUID();
    mBaseAmount = new BigDecimal(args.getString(UxArgument.AMOUNT_STRING));

    String conditions =
        "("
            + DatabaseSchema.AccountEntry.COLUMN_HIDDEN
            + " = 0 AND "
            + DatabaseSchema.AccountEntry.COLUMN_PLACEHOLDER
            + " = 0"
            + ")";
    mCursor = mAccountsDbAdapter.fetchAccountsOrderedByFullName(conditions, null);
    mCommodity =
        CommoditiesDbAdapter.getInstance()
            .getCommodity(mAccountsDbAdapter.getCurrencyCode(mAccountUID));
  }