- LinearLayout root = findViewById(R.id.account_root);
- root.removeAllViewsInLayout();
-
- try (Cursor cursor = db.rawQuery("SELECT name FROM accounts ORDER BY name;", null)) {
- boolean even = false;
- while (cursor.moveToNext()) {
- String acc_name = cursor.getString(0);
-
- TableLayout t = new TableLayout(this);
- TableRow r = new TableRow(this);
- r.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- r.setGravity(Gravity.CENTER_VERTICAL);
- r.setPadding(getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), dp2px(4), getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), dp2px(4));
- if (even)
- r.setBackgroundColor(getResources().getColor(R.color.table_row_even_bg, getTheme()));
- even = !even;
-
- TextView acc_tv = new TextView(this, null, R.style.account_summary_account_name);
- acc_tv.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 9f));
- acc_tv.setText(acc_name);
- r.addView(acc_tv);
-
- TextView amt_tv = new TextView(this, null, R.style.account_summary_amounts);
- amt_tv.setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
- amt_tv.setTextAlignment(EditText.TEXT_ALIGNMENT_VIEW_END);
- amt_tv.setGravity(Gravity.CENTER);
- amt_tv.setMinWidth(dp2px(40f));
- StringBuilder amt_text = new StringBuilder();
- try (Cursor cAmounts = db.rawQuery("SELECT currency, value FROM account_values WHERE account = ?", new String[]{acc_name})) {
- while (cAmounts.moveToNext()) {
- String curr = cAmounts.getString(0);
- Float amt = cAmounts.getFloat(1);
- if (amt_text.length() != 0) amt_text.append('\n');
- amt_text.append(String.format("%s %1.2f", curr, amt));
- }
- }
- amt_tv.setText(amt_text.toString());
-
- r.addView(amt_tv);
-
- t.addView(r);
-
- root.addView(t);
- }
+ model.reloadAccounts();
+ modelAdapter.notifyDataSetChanged();
+ }
+ void stopSelection() {
+ modelAdapter.stopSelection();
+ if (optMenu != null) {
+ optMenu.findItem(R.id.menu_acc_summary_cancel_selection).setVisible(false);
+ optMenu.findItem(R.id.menu_acc_summary_confirm_selection).setVisible(false);
+ optMenu.findItem(R.id.menu_acc_summary_only_starred).setVisible(true);
+ }
+ {
+ FloatingActionButton fab = findViewById(R.id.btn_add_transaction);
+ if (fab != null) fab.show();