From: Damyan Ivanov <dam+mobileledger@ktnx.net>
Date: Sat, 14 Mar 2020 16:45:00 +0000 (+0200)
Subject: NT: survive swiping away an account when only two accounts are present
X-Git-Tag: v0.12.0~71
X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=0804f05abcbb5a6b4300eac6f881cd9d59bb42bd;p=mobile-ledger.git

NT: survive swiping away an account when only two accounts are present

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
---

diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java
index 710b4d68..c9b9230e 100644
--- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java
+++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemsAdapter.java
@@ -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);
             }
         });
     }