-
- void reloadAccounts(Context context) {
- accounts.clear();
- boolean showingOnlyStarred =
- PreferenceManager.getDefaultSharedPreferences(getApplication())
- .getBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, false);
- String sql = "SELECT name, hidden FROM accounts";
- if (showingOnlyStarred) sql += " WHERE hidden = 0";
- sql += " ORDER BY name";
-
- try (SQLiteDatabase db = MLDB.getReadableDatabase()) {
- try (Cursor cursor = db
- .rawQuery(sql,null))
- {
- while (cursor.moveToNext()) {
- LedgerAccount acc = new LedgerAccount(cursor.getString(0));
- acc.setHidden(cursor.getInt(1) == 1);
- try (Cursor c2 = db.rawQuery(
- "SELECT value, currency FROM account_values " + "WHERE account = ?",
- new String[]{acc.getName()}))
- {
- while (c2.moveToNext()) {
- acc.addAmount(c2.getFloat(0), c2.getString(1));
- }
- }
- accounts.add(acc);
- }
+ static void commitSelections(Context context) {
+ boolean showingOnlyStarred = PreferenceManager.getDefaultSharedPreferences(context)
+ .getBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, false);
+ CAT task = new CAT();
+ //noinspection unchecked
+ task.execute(new CommitAccountsTaskParams(Data.accounts.get(), showingOnlyStarred));
+ }
+ private static class UAT extends UpdateAccountsTask {
+ @Override
+ protected void onPostExecute(ArrayList<LedgerAccount> list) {
+ super.onPostExecute(list);
+ if (list != null) {
+ Log.d("acc", "setting updated account list");
+ Data.accounts.set(list);