From e4082dc33aa9c01f2ef16cdcd31e0f4e68b897c5 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 27 Mar 2021 08:14:21 +0100 Subject: [PATCH] Restore search --- .../main/java/eu/faircode/email/AdapterAnswer.java | 3 ++- .../main/java/eu/faircode/email/AdapterContact.java | 3 ++- app/src/main/java/eu/faircode/email/AdapterRule.java | 3 ++- .../main/java/eu/faircode/email/FragmentAnswers.java | 11 ++++++----- .../main/java/eu/faircode/email/FragmentContacts.java | 11 ++++++----- .../main/java/eu/faircode/email/FragmentRules.java | 11 ++++++----- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterAnswer.java b/app/src/main/java/eu/faircode/email/AdapterAnswer.java index 73b1964d87..352c6e9acf 100644 --- a/app/src/main/java/eu/faircode/email/AdapterAnswer.java +++ b/app/src/main/java/eu/faircode/email/AdapterAnswer.java @@ -236,7 +236,7 @@ public class AdapterAnswer extends RecyclerView.Adapter answers) { - Log.i("Set answers=" + answers.size()); + Log.i("Set answers=" + answers.size() + " search=" + search); all = answers; @@ -283,6 +283,7 @@ public class AdapterAnswer extends RecyclerView.Adapter>() { @@ -164,8 +163,10 @@ public class FragmentAnswers extends FragmentBase { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { - searching = newText; - adapter.search(newText); + if (getView() != null) { + searching = newText; + adapter.search(newText); + } return true; } diff --git a/app/src/main/java/eu/faircode/email/FragmentContacts.java b/app/src/main/java/eu/faircode/email/FragmentContacts.java index 4d9cd0b823..9e20038377 100644 --- a/app/src/main/java/eu/faircode/email/FragmentContacts.java +++ b/app/src/main/java/eu/faircode/email/FragmentContacts.java @@ -92,10 +92,9 @@ public class FragmentContacts extends FragmentBase { public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - if (savedInstanceState != null) { + if (savedInstanceState != null) searching = savedInstanceState.getString("fair:searching"); - adapter.search(searching); - } + adapter.search(searching); DB db = DB.getInstance(getContext()); db.contact().liveContacts().observe(getViewLifecycleOwner(), new Observer>() { @@ -130,8 +129,10 @@ public class FragmentContacts extends FragmentBase { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { - searching = newText; - adapter.search(newText); + if (getView() != null) { + searching = newText; + adapter.search(newText); + } return true; } diff --git a/app/src/main/java/eu/faircode/email/FragmentRules.java b/app/src/main/java/eu/faircode/email/FragmentRules.java index fa210139dc..013bec4442 100644 --- a/app/src/main/java/eu/faircode/email/FragmentRules.java +++ b/app/src/main/java/eu/faircode/email/FragmentRules.java @@ -172,10 +172,9 @@ public class FragmentRules extends FragmentBase { public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - if (savedInstanceState != null) { + if (savedInstanceState != null) searching = savedInstanceState.getString("fair:searching"); - adapter.search(searching); - } + adapter.search(searching); DB db = DB.getInstance(getContext()); db.rule().liveRules(folder).observe(getViewLifecycleOwner(), new Observer>() { @@ -236,8 +235,10 @@ public class FragmentRules extends FragmentBase { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { - searching = newText; - adapter.search(newText); + if (getView() != null) { + searching = newText; + adapter.search(newText); + } return true; }