示例#1
0
 public QifExport(Context context, DatabaseAdapter db, QifExportOptions options) {
   super(context, false);
   this.db = db;
   this.em = db.em();
   this.options = options;
   this.categories = db.getCategoriesTree(false);
   this.categoriesMap = categories.asMap();
   this.accountsMap = db.em().getAllAccountsMap();
 }
示例#2
0
 private static RemoteViews buildUpdateForNextAccount(
     Context context, int widgetId, int layoutId, Class providerClass, long accountId) {
   DatabaseAdapter db = new DatabaseAdapter(context);
   db.open();
   try {
     MyEntityManager em = db.em();
     Cursor c = em.getAllActiveAccounts();
     try {
       int count = c.getCount();
       if (count > 0) {
         Log.d("FinancistoWidget", "buildUpdateForNextAccount " + widgetId + " -> " + accountId);
         if (count == 1 || accountId == -1) {
           if (c.moveToNext()) {
             Account a = EntityManager.loadFromCursor(c, Account.class);
             return updateWidgetFromAccount(context, widgetId, layoutId, providerClass, a);
           }
         } else {
           boolean found = false;
           while (c.moveToNext()) {
             Account a = EntityManager.loadFromCursor(c, Account.class);
             if (a.id == accountId) {
               found = true;
               Log.d("FinancistoWidget", "buildUpdateForNextAccount found -> " + accountId);
             } else {
               if (found) {
                 Log.d(
                     "FinancistoWidget",
                     "buildUpdateForNextAccount building update for -> " + a.id);
                 return updateWidgetFromAccount(context, widgetId, layoutId, providerClass, a);
               }
             }
           }
           c.moveToFirst();
           Account a = EntityManager.loadFromCursor(c, Account.class);
           Log.d(
               "FinancistoWidget",
               "buildUpdateForNextAccount not found, taking the first one -> " + a.id);
           return updateWidgetFromAccount(context, widgetId, layoutId, providerClass, a);
         }
       }
       return noDataUpdate(context, layoutId);
     } finally {
       c.close();
     }
   } catch (Exception ex) {
     return errorUpdate(context);
   } finally {
     db.close();
   }
 }
示例#3
0
 private void writeAccountsAndTransactions(QifBufferedWriter qifWriter) throws IOException {
   List<Account> accounts = db.em().getAllAccountsList();
   for (Account a : accounts) {
     if (isSelectedAccount(a)) {
       QifAccount qifAccount = writeAccount(qifWriter, a);
       writeTransactionsForAccount(qifWriter, qifAccount, a);
     }
   }
 }
示例#4
0
 private static RemoteViews buildUpdateForCurrentAccount(
     Context context, int widgetId, int layoutId, Class providerClass, long accountId) {
   DatabaseAdapter db = new DatabaseAdapter(context);
   db.open();
   try {
     MyEntityManager em = db.em();
     Account a = em.getAccount(accountId);
     if (a != null) {
       Log.d(
           "FinancistoWidget",
           "buildUpdateForCurrentAccount building update for " + widgetId + " -> " + accountId);
       return updateWidgetFromAccount(context, widgetId, layoutId, providerClass, a);
     } else {
       Log.d(
           "FinancistoWidget",
           "buildUpdateForCurrentAccount not found " + widgetId + " -> " + accountId);
       return buildUpdateForNextAccount(context, widgetId, layoutId, providerClass, -1);
     }
   } catch (Exception ex) {
     return errorUpdate(context);
   } finally {
     db.close();
   }
 }
 public CategoryTreeNavigator(DatabaseAdapter db) {
   this.db = db;
   this.categories = db.getCategoriesTree(false);
   Category noCategory = db.getCategory(Category.NO_CATEGORY_ID);
   tagCategories(noCategory);
 }
 public void addSplitCategoryToTheTop() {
   Category splitCategory = db.getCategory(Category.SPLIT_CATEGORY_ID);
   categories.insertAtTop(splitCategory);
 }
示例#7
0
 private Cursor getBlotterForAccount(Account account) {
   WhereFilter accountFilter = WhereFilter.copyOf(options.filter);
   accountFilter.put(Criteria.eq(BlotterFilter.FROM_ACCOUNT_ID, String.valueOf(account.id)));
   return db.getBlotterForAccount(accountFilter);
 }