+ table = findViewById(R.id.new_transaction_accounts_table);
+ for (int i = 0; i < table.getChildCount(); i++) {
+ hook_swipe_listener((TableRow)table.getChildAt(i));
+// Log.d("swipe", "hooked to row "+i);
+ }
+ }
+
+ private void hook_swipe_listener(final TableRow row) {
+ row.getChildAt(0).setOnTouchListener(new OnSwipeTouchListener(this) {
+ public void onSwipeLeft() {
+// Log.d("swipe", "LEFT" + row.getId());
+ if (table.getChildCount() > 2) {
+ table.removeView(row);
+// Toast.makeText(NewTransactionActivity.this, "LEFT", Toast.LENGTH_LONG).show();
+ }
+ else {
+ Snackbar.make(table, R.string.msg_at_least_two_accounts_are_required, Snackbar.LENGTH_LONG)
+ .setAction("Action", null).show();
+ }
+ }
+// @Override
+// public boolean performClick(View view, MotionEvent m) {
+// return true;
+// }
+ public boolean onTouch(View view, MotionEvent m) {
+ return gestureDetector.onTouchEvent(m);
+ }
+ });