+ public void save_transaction() {
+ mSave.setVisible(false);
+ toggle_all_editing(false);
+ progress.setVisibility(View.VISIBLE);
+
+ saver = new SaveTransactionTask(this);
+
+ saver.setPref(PreferenceManager.getDefaultSharedPreferences(this));
+ LedgerTransaction tr = new LedgerTransaction(text_date.getText().toString(), text_descr.getText().toString());
+
+ TableLayout table = findViewById(R.id.new_transaction_accounts_table);
+ for ( int i = 0; i < table.getChildCount(); i++ ) {
+ TableRow row = (TableRow) table.getChildAt(i);
+ String acc = ((TextView) row.getChildAt(0)).getText().toString();
+ String amt = ((TextView) row.getChildAt(1)).getText().toString();
+ LedgerTransactionItem item =
+ amt.length() > 0
+ ? new LedgerTransactionItem( acc, Float.parseFloat(amt))
+ : new LedgerTransactionItem( acc );
+
+ tr.add_item(item);
+ }
+ saver.execute(tr);
+ }
+
+ private void toggle_all_editing(boolean enabled) {
+ TableLayout table = findViewById(R.id.new_transaction_accounts_table);
+ for (int i = 0; i < table.getChildCount(); i++) {
+ TableRow row = (TableRow) table.getChildAt(i);
+ for (int j = 0; j < row.getChildCount(); j++) {
+ row.getChildAt(j).setEnabled(enabled);
+ }
+ }
+ }
+