Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 49710d2

Browse files
author
Alexander Sokol
committed
fix text change with an empty string after search action is submitted
1 parent fcd6b25 commit 49710d2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

simplesearchview/src/main/java/com/ferfalk/simplesearchview/SimpleSearchView.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public class SimpleSearchView extends FrameLayout {
9292
private OnQueryTextListener onQueryChangeListener;
9393
private SearchViewListener searchViewListener;
9494

95+
private boolean searchIsClosing = false;
96+
9597
public SimpleSearchView(Context context) {
9698
this(context, null);
9799
}
@@ -209,7 +211,9 @@ private void initSearchEditText() {
209211
searchEditText.addTextChangedListener(new SimpleTextWatcher() {
210212
@Override
211213
public void onTextChanged(CharSequence s, int start, int before, int count) {
212-
SimpleSearchView.this.onTextChanged(s);
214+
if (!searchIsClosing) {
215+
SimpleSearchView.this.onTextChanged(s);
216+
}
213217
}
214218
});
215219

@@ -320,7 +324,9 @@ private void onSubmitQuery() {
320324
if (submittedQuery != null && TextUtils.getTrimmedLength(submittedQuery) > 0) {
321325
if (onQueryChangeListener == null || !onQueryChangeListener.onQueryTextSubmit(submittedQuery.toString())) {
322326
closeSearch();
327+
searchIsClosing = true;
323328
searchEditText.setText(null);
329+
searchIsClosing = false;
324330
}
325331
}
326332
}
@@ -394,7 +400,9 @@ public void closeSearch(boolean animate) {
394400
return;
395401
}
396402

403+
searchIsClosing = true;
397404
searchEditText.setText(null);
405+
searchIsClosing = false;
398406
clearFocus();
399407

400408
if (animate) {

0 commit comments

Comments
 (0)