import android.widget.TableRow;
import android.widget.TextView;
+import java.util.Date;
import java.util.Objects;
/*
});
text_descr = findViewById(R.id.new_transaction_description);
hook_autocompletion_adapter(text_descr, MobileLedgerDB.DESCRIPTION_HISTORY_TABLE, "description");
+ hook_text_change_listener(text_descr);
progress = findViewById(R.id.save_transaction_progress);
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
table = findViewById(R.id.new_transaction_accounts_table);
- table.removeAllViews();
- do_add_account_row(false);
- do_add_account_row(false);
+ for (int i = 0; i < table.getChildCount(); i++) {
+ TableRow row = (TableRow) table.getChildAt(i);
+ AutoCompleteTextView acc_name_view = (AutoCompleteTextView) row.getChildAt(0);
+ TextView amount_view = (TextView) row.getChildAt(1);
+ hook_swipe_listener(row);
+ hook_autocompletion_adapter(acc_name_view, MobileLedgerDB.ACCOUNTS_TABLE, "name");
+ hook_text_change_listener(acc_name_view);
+ hook_text_change_listener(amount_view);
+// Log.d("swipe", "hooked to row "+i);
+ }
}
@Override
saver = new SaveTransactionTask(this);
saver.setPref(PreferenceManager.getDefaultSharedPreferences(this));
- LedgerTransaction tr = new LedgerTransaction(text_date.getText().toString(), text_descr.getText().toString());
+ String date = text_date.getText().toString();
+ if (date.isEmpty()) date = String.valueOf(new Date().getDate());
+ LedgerTransaction tr = new LedgerTransaction(date, text_descr.getText().toString());
TableLayout table = findViewById(R.id.new_transaction_accounts_table);
for ( int i = 0; i < table.getChildCount(); i++ ) {
private void reset_form() {
text_date.setText("");
text_descr.setText("");
+
+ text_descr.requestFocus();
+
while(table.getChildCount() > 2) {
table.removeViewAt(2);
}
((TextView)tr.getChildAt(0)).setText("");
((TextView)tr.getChildAt(1)).setText("");
}
-
- text_descr.requestFocus();
}
}