From 94270f0986ed02ae35efe770f9fd0163f83313ed Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 21 Sep 2019 20:52:04 +0300 Subject: [PATCH] AutoWithClear: manage the drawable on text change only if having focus --- .../ktnx/mobileledger/ui/AutoCompleteTextViewWithClear.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/AutoCompleteTextViewWithClear.java b/app/src/main/java/net/ktnx/mobileledger/ui/AutoCompleteTextViewWithClear.java index 8b714dac..8b73de1d 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/AutoCompleteTextViewWithClear.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/AutoCompleteTextViewWithClear.java @@ -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; -- 2.39.5