]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java
new transaction: remove the xml-driven rows and populate by hand
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / NewTransactionActivity.java
index ca1812008e53fecc06d9f588fcc42abbec058b09..ca2407db85fc5e2967031a7581e0e3d3ddf8fd0b 100644 (file)
@@ -64,6 +64,13 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal
         setSupportActionBar(toolbar);
 
         text_date = findViewById(R.id.new_transaction_date);
+        text_date.setOnFocusChangeListener(new View.OnFocusChangeListener() {
+            @Override
+            public
+            void onFocusChange(View v, boolean hasFocus) {
+                if (hasFocus) pickTransactionDate(v);
+            }
+        });
         text_descr = findViewById(R.id.new_transaction_description);
         hook_autocompletion_adapter(text_descr, MobileLedgerDB.DESCRIPTION_HISTORY_TABLE, "description");
 
@@ -71,16 +78,9 @@ public class NewTransactionActivity extends AppCompatActivity implements TaskCal
 
         Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
         table = findViewById(R.id.new_transaction_accounts_table);
-        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);
-        }
+        table.removeAllViews();
+        do_add_account_row(false);
+        do_add_account_row(false);
     }
 
     @Override