]> git.ktnx.net Git - mobile-ledger.git/commitdiff
AutoWithClear: manage the drawable on text change only if having focus
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 21 Sep 2019 17:52:04 +0000 (20:52 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 21 Sep 2019 17:52:04 +0000 (20:52 +0300)
app/src/main/java/net/ktnx/mobileledger/ui/AutoCompleteTextViewWithClear.java

index 8b714dac29de31de0f7edbb4ed6d666cfe1f5e2f..8b73de1d331c68c4ff7207c2e2913ae446c82332 100644 (file)
@@ -63,8 +63,10 @@ public final class AutoCompleteTextViewWithClear extends AppCompatAutoCompleteTe
     protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
         final boolean hasText = text.length() > 0;
 
-        if (hadText && !hasText) hideClearDrawable();
-        if (!hadText && hasText) showClearDrawable();
+        if (hasFocus()) {
+            if (hadText && !hasText) hideClearDrawable();
+            if (!hadText && hasText) showClearDrawable();
+        }
 
         hadText = hasText;