- public Calendar getFirstTransactionDate() {
- return firstTransactionDate;
- }
- public Calendar getLastTransactionDate() {
- return lastTransactionDate;
- }
- private void applyTransactionFilter(List<LedgerTransaction> list) {
- final String accFilter = Data.accountFilter.getValue();
- if (TextUtils.isEmpty(accFilter)) {
- displayedTransactions.postValue(list);
- }
- else {
- ArrayList<LedgerTransaction> newList = new ArrayList<>();
- for (LedgerTransaction tr : list) {
- if (tr.hasAccountNamedLike(accFilter))
- newList.add(tr);
- }
- displayedTransactions.postValue(newList);
- }
- }
- synchronized public void storeAccountListAsync(List<LedgerAccount> list,
- boolean storeUiFields) {
- if (accountListSaver != null)
- accountListSaver.interrupt();
- accountListSaver = new AccountListSaver(this, list, storeUiFields);
- accountListSaver.start();
- }
- public void setAndStoreAccountListFromWeb(ArrayList<LedgerAccount> list) {
- SQLiteDatabase db = App.getDatabase();
- db.beginTransactionNonExclusive();
- try {
- markAccountsAsNotPresent(db);
- for (LedgerAccount acc : list) {
- storeAccount(db, acc, false);
- for (LedgerAmount amt : acc.getAmounts()) {
- storeAccountValue(db, acc.getName(), amt.getCurrency(), amt.getAmount());
- }
- }
- deleteNotPresentAccounts(db);
- setLastUpdateStamp();
- db.setTransactionSuccessful();
- }
- finally {
- db.endTransaction();
- }
-
- mergeAccountListFromWeb(list);
- updateDisplayedAccounts();
- }
- public synchronized Locker lockAccountsForWriting() {
- accountsLocker.lockForWriting();
- return accountsLocker;
- }
- public void setAndStoreTransactionList(ArrayList<LedgerTransaction> list) {
- storeTransactionListAsync(this, list);
- SQLiteDatabase db = App.getDatabase();
- db.beginTransactionNonExclusive();
- try {
- markTransactionsAsNotPresent(db);
- for (LedgerTransaction tr : list)
- storeTransaction(db, tr);
- deleteNotPresentTransactions(db);
- setLastUpdateStamp();
- db.setTransactionSuccessful();
- }
- finally {
- db.endTransaction();
- }
-
- allTransactions.postValue(list);
- }
- private void storeTransactionListAsync(MobileLedgerProfile mobileLedgerProfile,
- List<LedgerTransaction> list) {
- if (transactionListSaver != null)
- transactionListSaver.interrupt();
-
- transactionListSaver = new TransactionListSaver(this, list);
- transactionListSaver.start();
- }
- public void setAndStoreAccountAndTransactionListFromWeb(List<LedgerAccount> accounts,
- List<LedgerTransaction> transactions) {
- storeAccountAndTransactionListAsync(accounts, transactions, false);
-
- mergeAccountListFromWeb(accounts);
- updateDisplayedAccounts();
-
- allTransactions.postValue(transactions);
- }
- private void storeAccountAndTransactionListAsync(List<LedgerAccount> accounts,
- List<LedgerTransaction> transactions,
- boolean storeAccUiFields) {