From 43dc9b9ff901fcdcb2602c0a6b54281469208fcd Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 16 May 2022 10:23:27 +0200 Subject: [PATCH] Fixed search interaction --- .../main/java/eu/faircode/email/FragmentAnswers.java | 10 +--------- .../main/java/eu/faircode/email/FragmentContacts.java | 10 +--------- .../main/java/eu/faircode/email/FragmentFolders.java | 10 +--------- app/src/main/java/eu/faircode/email/FragmentRules.java | 10 +--------- 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentAnswers.java b/app/src/main/java/eu/faircode/email/FragmentAnswers.java index 0b4abe6130..490cab2474 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAnswers.java +++ b/app/src/main/java/eu/faircode/email/FragmentAnswers.java @@ -233,18 +233,10 @@ public class FragmentAnswers extends FragmentBase { searchView.setQuery(searching, true); } - getViewLifecycleOwner().getLifecycle().addObserver(new LifecycleObserver() { - @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) - public void onDestroyed() { - menuSearch.collapseActionView(); - getViewLifecycleOwner().getLifecycle().removeObserver(this); - } - }); - searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { - if (getView() != null) { + if (getView() != null && menuSearch.isActionViewExpanded()) { searching = newText; adapter.search(newText); } diff --git a/app/src/main/java/eu/faircode/email/FragmentContacts.java b/app/src/main/java/eu/faircode/email/FragmentContacts.java index 9dbca2cc20..ee9fd57ce0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentContacts.java +++ b/app/src/main/java/eu/faircode/email/FragmentContacts.java @@ -211,18 +211,10 @@ public class FragmentContacts extends FragmentBase { searchView.setQuery(searching, true); } - getViewLifecycleOwner().getLifecycle().addObserver(new LifecycleObserver() { - @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) - public void onDestroyed() { - menuSearch.collapseActionView(); - getViewLifecycleOwner().getLifecycle().removeObserver(this); - } - }); - searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { - if (getView() != null) { + if (getView() != null && menuSearch.isActionViewExpanded()) { searching = newText; adapter.search(newText); } diff --git a/app/src/main/java/eu/faircode/email/FragmentFolders.java b/app/src/main/java/eu/faircode/email/FragmentFolders.java index de9a397248..7f9d7e8ed1 100644 --- a/app/src/main/java/eu/faircode/email/FragmentFolders.java +++ b/app/src/main/java/eu/faircode/email/FragmentFolders.java @@ -611,18 +611,10 @@ public class FragmentFolders extends FragmentBase { searchView.setQuery(searching, true); } - getViewLifecycleOwner().getLifecycle().addObserver(new LifecycleObserver() { - @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) - public void onDestroyed() { - menuSearch.collapseActionView(); - getViewLifecycleOwner().getLifecycle().removeObserver(this); - } - }); - searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { - if (getView() != null) { + if (getView() != null && menuSearch.isActionViewExpanded()) { searching = newText; adapter.search(newText); } diff --git a/app/src/main/java/eu/faircode/email/FragmentRules.java b/app/src/main/java/eu/faircode/email/FragmentRules.java index 7f5c67a374..324fab04bc 100644 --- a/app/src/main/java/eu/faircode/email/FragmentRules.java +++ b/app/src/main/java/eu/faircode/email/FragmentRules.java @@ -228,18 +228,10 @@ public class FragmentRules extends FragmentBase { searchView.setQuery(searching, true); } - getViewLifecycleOwner().getLifecycle().addObserver(new LifecycleObserver() { - @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) - public void onDestroyed() { - menuSearch.collapseActionView(); - getViewLifecycleOwner().getLifecycle().removeObserver(this); - } - }); - searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { - if (getView() != null) { + if (getView() != null && menuSearch.isActionViewExpanded()) { searching = newText; adapter.search(newText); }