]> git.ktnx.net Git - mobile-ledger-staging.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java
fix many lint errors/warnings
[mobile-ledger-staging.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / NewTransactionItemHolder.java
index e311eb94ba450c9542ef9f0151328ddb2003853d..21c0ce28b881f84f52243452356890d8ee31a126 100644 (file)
@@ -65,36 +65,35 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
     private final TextView tvCurrency;
     private final Observer<Boolean> showCommentsObserver;
     private final TextView tvTransactionComment;
+    private final TextView tvDate;
+    private final AutoCompleteTextView tvDescription;
+    private final TextView tvDummy;
+    private final AutoCompleteTextView tvAccount;
+    private final TextView tvComment;
+    private final EditText tvAmount;
+    private final ViewGroup lHead;
+    private final ViewGroup lAccount;
+    private final FrameLayout lPadding;
+    private final MobileLedgerProfile mProfile;
+    private final Observer<SimpleDate> dateObserver;
+    private final Observer<String> descriptionObserver;
+    private final Observer<String> transactionCommentObserver;
+    private final Observer<String> hintObserver;
+    private final Observer<Integer> focusedAccountObserver;
+    private final Observer<Integer> accountCountObserver;
+    private final Observer<Boolean> editableObserver;
+    private final Observer<Currency.Position> currencyPositionObserver;
+    private final Observer<Boolean> currencyGapObserver;
+    private final Observer<Locale> localeObserver;
+    private final Observer<Currency> currencyObserver;
+    private final Observer<Boolean> showCurrencyObserver;
+    private final Observer<String> commentObserver;
+    private final Observer<Boolean> amountValidityObserver;
     private String decimalSeparator;
     private NewTransactionModel.Item item;
-    private TextView tvDate;
-    private AutoCompleteTextView tvDescription;
-    private TextView tvDummy;
-    private AutoCompleteTextView tvAccount;
-    private TextView tvComment;
-    private EditText tvAmount;
-    private ViewGroup lHead;
-    private ViewGroup lAccount;
-    private FrameLayout lPadding;
-    private MobileLedgerProfile mProfile;
     private Date date;
-    private Observer<SimpleDate> dateObserver;
-    private Observer<String> descriptionObserver;
-    private Observer<String> transactionCommentObserver;
-    private Observer<String> hintObserver;
-    private Observer<Integer> focusedAccountObserver;
-    private Observer<Integer> accountCountObserver;
-    private Observer<Boolean> editableObserver;
-    private Observer<Currency.Position> currencyPositionObserver;
-    private Observer<Boolean> currencyGapObserver;
-    private Observer<Locale> localeObserver;
-    private Observer<Currency> currencyObserver;
-    private Observer<Boolean> showCurrencyObserver;
-    private Observer<String> commentObserver;
-    private Observer<Boolean> amountValidityObserver;
     private boolean inUpdate = false;
     private boolean syncingData = false;
-    private View commentButton;
     //TODO multiple amounts with different currencies per posting
     NewTransactionItemHolder(@NonNull View itemView, NewTransactionItemsAdapter adapter) {
         super(itemView);
@@ -103,7 +102,6 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
         tvComment = lAccount.findViewById(R.id.comment);
         tvTransactionComment = itemView.findViewById(R.id.transaction_comment);
         new TextViewClearHelper().attachToTextView((EditText) tvComment);
-        commentButton = lAccount.findViewById(R.id.comment_button);
         tvAmount = itemView.findViewById(R.id.account_row_acc_amounts);
         tvCurrency = itemView.findViewById(R.id.currency);
         tvDate = itemView.findViewById(R.id.new_transaction_date);
@@ -121,10 +119,11 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
 
         tvDate.setOnClickListener(v -> pickTransactionDate());
 
-        commentButton.setOnClickListener(v -> {
-            tvComment.setVisibility(View.VISIBLE);
-            tvComment.requestFocus();
-        });
+        lAccount.findViewById(R.id.comment_button)
+                .setOnClickListener(v -> {
+                    tvComment.setVisibility(View.VISIBLE);
+                    tvComment.requestFocus();
+                });
 
         transactionCommentLayout.findViewById(R.id.comment_button)
                                 .setOnClickListener(v -> {
@@ -186,10 +185,9 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
 
         decimalSeparator = String.valueOf(DecimalFormatSymbols.getInstance()
                                                               .getMonetaryDecimalSeparator());
-        localeObserver = locale -> {
-            decimalSeparator = String.valueOf(DecimalFormatSymbols.getInstance(locale)
-                                                                  .getMonetaryDecimalSeparator());
-        };
+        localeObserver = locale -> decimalSeparator = String.valueOf(
+                DecimalFormatSymbols.getInstance(locale)
+                                    .getMonetaryDecimalSeparator());
 
         decimalDot = ".";
 
@@ -685,7 +683,7 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
                 final NewTransactionActivity activity =
                         (NewTransactionActivity) tvDescription.getContext();
 
-                if (!item.isOfType(ItemType.bottomFiller)) {
+                if (!item.isBottomFiller()) {
                     item.observeEditableFlag(activity, editableObserver);
                     item.getModel()
                         .observeFocusedItem(activity, focusedAccountObserver);
@@ -719,7 +717,7 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
     }
     @Override
     public void onDatePicked(int year, int month, int day) {
-        item.setDate(new SimpleDate(year, month+1, day));
+        item.setDate(new SimpleDate(year, month + 1, day));
         boolean focused = tvDescription.requestFocus();
         if (focused)
             Misc.showSoftKeyboard((NewTransactionActivity) tvAccount.getContext());