]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemHolder.java
fix model inconsistency when hiding/showing currency
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / new_transaction / NewTransactionItemHolder.java
index c6232d167f7e303af4d93be2222354918727cc36..3b69110a7c99cb8f75dc41e16e42c3a32f3e0da9 100644 (file)
@@ -230,12 +230,12 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
                          if (showCurrency) {
                              b.currency.setVisibility(View.VISIBLE);
                              b.currencyButton.setVisibility(View.VISIBLE);
-                             b.currency.setText(mProfile.getDefaultCommodity());
+                             setCurrencyString(mProfile.getDefaultCommodity());
                          }
                          else {
                              b.currency.setVisibility(View.GONE);
                              b.currencyButton.setVisibility(View.GONE);
-                             b.currency.setText(null);
+                             setCurrencyString(null);
                          }
                      });
 
@@ -436,7 +436,7 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
     private void setCurrencyString(String currency) {
         @ColorInt int textColor = b.dummyText.getTextColors()
                                              .getDefaultColor();
-        if ((currency == null) || currency.isEmpty()) {
+        if (TextUtils.isEmpty(currency)) {
             b.currency.setText(R.string.currency_symbol);
             int alpha = (textColor >> 24) & 0xff;
             alpha = alpha * 3 / 4;
@@ -626,9 +626,7 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
                         try {
                             b.accountRowAccName.setAdapter(null);
                             b.accountRowAccName.setText(incomingAccountName);
-                            if (b.accountRowAccName.hasFocus())
-                                b.accountRowAccName.setSelection(
-                                        acc.getAccountNameCursorPosition());
+                            b.accountRowAccName.setSelection(acc.getAccountNameCursorPosition());
                         }
                         finally {
                             b.accountRowAccName.setAdapter(a);