]> git.ktnx.net Git - mobile-ledger.git/commitdiff
convert switch on resource IDs with a series of if/else
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 2 Jan 2021 16:16:43 +0000 (18:16 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 2 Jan 2021 16:16:43 +0000 (18:16 +0200)
resource IDs are going to be non-final in the future

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

index b2dd24dac890eef4b68bf3a0be189caf2b977c7b..f8d6002be3635d4fef7ca6b0acfdb0736886a496 100644 (file)
@@ -144,22 +144,20 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
                 try {
                     final int pos = getAdapterPosition();
                     adapter.updateFocusedItem(pos);
-                    switch (id) {
-                        case R.id.account_row_acc_name:
-                            adapter.noteFocusIsOnAccount(pos);
-                            break;
-                        case R.id.account_row_acc_amounts:
-                            adapter.noteFocusIsOnAmount(pos);
-                            break;
-                        case R.id.comment:
-                            adapter.noteFocusIsOnComment(pos);
-                            break;
-                        case R.id.transaction_comment:
-                            adapter.noteFocusIsOnTransactionComment(pos);
-                            break;
-                        case R.id.new_transaction_description:
-                            adapter.noteFocusIsOnDescription(pos);
-                            break;
+                    if (id == R.id.account_row_acc_name) {
+                        adapter.noteFocusIsOnAccount(pos);
+                    }
+                    else if (id == R.id.account_row_acc_amounts) {
+                        adapter.noteFocusIsOnAmount(pos);
+                    }
+                    else if (id == R.id.comment) {
+                        adapter.noteFocusIsOnComment(pos);
+                    }
+                    else if (id == R.id.transaction_comment) {
+                        adapter.noteFocusIsOnTransactionComment(pos);
+                    }
+                    else if (id == R.id.new_transaction_description) {
+                        adapter.noteFocusIsOnDescription(pos);
                     }
                 }
                 finally {