+ hook_text_change_listener(acc);
+ hook_text_change_listener(amt);
+ }
+
+ public void addTransactionAccountFromMenu(MenuItem item) {
+ do_add_account_row(true);
+ }
+
+ public void saveTransactionFromMenu(MenuItem item) {
+ save_transaction();
+ }
+
+ private void check_transaction_submittable() {
+ TableLayout table = findViewById(R.id.new_transaction_accounts_table);
+ int accounts = 0;
+ int accounts_with_values = 0;
+ int empty_rows = 0;
+ for(int i = 0; i < table.getChildCount(); i++ ) {
+ TableRow row = (TableRow) table.getChildAt(i);
+
+ TextView acc_name_v = (TextView) row.getChildAt(0);
+
+ String acc_name = String.valueOf(acc_name_v.getText());
+ acc_name = acc_name.trim();
+ if (!acc_name.isEmpty()) {
+ accounts++;
+
+ TextView amount_v = (TextView) row.getChildAt(1);
+ String amt = String.valueOf(amount_v.getText());
+
+ if (!amt.isEmpty()) accounts_with_values++;
+ } else empty_rows++;
+ }
+
+ if (accounts_with_values == accounts && empty_rows == 0) {
+ do_add_account_row(false);
+ }
+
+ if ((accounts >= 2) && (accounts_with_values >= (accounts - 1))) {
+ mSave.setVisible(true);
+ } else {
+ mSave.setVisible(false);
+ }