]> git.ktnx.net Git - mobile-ledger.git/commitdiff
NT: survive swiping away an account when only two accounts are present
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 14 Mar 2020 16:45:00 +0000 (18:45 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 14 Mar 2020 16:45:00 +0000 (18:45 +0200)
the old code ignored the swipe, but did not null it, so the UI was still
left with only one account

the new code accounts for the swipe as usual and lets
viewModel.checkTransactionSubmittable add the now missing account row

app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java

index 710b4d682e1cbace0703111b010042141c9e6aca..c9b9230e1235891ff0e018e1fe3a2cd32c7a68da 100644 (file)
@@ -108,18 +108,11 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter<NewTransactionItem
             }
             @Override
             public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
-                if (viewModel.getAccountCount() == 2)
-                    Snackbar.make(recyclerView, R.string.msg_at_least_two_accounts_are_required,
-                            Snackbar.LENGTH_LONG)
-                            .setAction("Action", null)
-                            .show();
-                else {
-                    int pos = viewHolder.getAdapterPosition();
-                    viewModel.removeItem(pos - 1);
-                    notifyItemRemoved(pos);
-                    viewModel.sendCountNotifications(); // needed after items re-arrangement
-                    viewModel.checkTransactionSubmittable(adapter);
-                }
+                int pos = viewHolder.getAdapterPosition();
+                viewModel.removeItem(pos - 1);
+                notifyItemRemoved(pos);
+                viewModel.sendCountNotifications(); // needed after items re-arrangement
+                viewModel.checkTransactionSubmittable(adapter);
             }
         });
     }