+ private void check_transaction_submittable() {
+ TableLayout table = findViewById(R.id.new_transaction_accounts_table);
+ int accounts = 0;
+ int accounts_with_values = 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++;
+ }
+
+ if ((accounts >= 2) && (accounts_with_values >= (accounts - 1))) {
+ show_fab();
+ return;
+ }
+ }
+
+ hide_fab();
+ }
+
+ @Override
+ public void done() {
+ fab.setImageResource(R.drawable.ic_check_white_24dp);
+ progress.setVisibility(View.INVISIBLE);
+ Log.d("visuals", "hiding progress");
+
+ fab_should_be_visible = false;
+ final Handler fade_out = new Handler();
+ fade_out.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ Log.d("visuals", "hiding FAB");
+
+ hide_fab(true);
+ }
+ }, 1000);
+ reset_form();
+ }
+
+ private void reset_form() {
+ text_date.setText("");
+ text_descr.setText("");
+ while(table.getChildCount() > 2) {
+ table.removeViewAt(2);
+ }
+ for( int i = 0; i < 2; i++ ) {
+ TableRow tr = (TableRow) table.getChildAt(i);
+ if ( tr == null) break;
+
+ ((TextView)tr.getChildAt(0)).setText("");
+ ((TextView)tr.getChildAt(1)).setText("");
+ }
+
+ text_descr.requestFocus();
+ }