Restore search

pull/196/head
M66B 4 years ago
parent 2b1b4c3a42
commit e4082dc33a

@ -236,7 +236,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
} }
public void set(@NonNull List<EntityAnswer> answers) { public void set(@NonNull List<EntityAnswer> answers) {
Log.i("Set answers=" + answers.size()); Log.i("Set answers=" + answers.size() + " search=" + search);
all = answers; all = answers;
@ -283,6 +283,7 @@ public class AdapterAnswer extends RecyclerView.Adapter<AdapterAnswer.ViewHolder
} }
public void search(String query) { public void search(String query) {
Log.i("Answers query=" + query);
search = query; search = query;
set(all); set(all);
} }

@ -363,7 +363,7 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
} }
public void set(@NonNull List<TupleContactEx> contacts) { public void set(@NonNull List<TupleContactEx> contacts) {
Log.i("Set contacts=" + contacts.size()); Log.i("Set contacts=" + contacts.size() + " search=" + search);
all = contacts; all = contacts;
@ -408,6 +408,7 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
} }
public void search(String query) { public void search(String query) {
Log.i("Contacts query=" + query);
search = query; search = query;
set(all); set(all);
} }

@ -425,7 +425,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
public void set(int protocol, @NonNull List<TupleRuleEx> rules) { public void set(int protocol, @NonNull List<TupleRuleEx> rules) {
this.protocol = protocol; this.protocol = protocol;
Log.i("Set protocol=" + protocol + " rules=" + rules.size()); Log.i("Set protocol=" + protocol + " rules=" + rules.size() + " search=" + search);
all = rules; all = rules;
@ -484,6 +484,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> {
} }
public void search(String query) { public void search(String query) {
Log.i("Rules query=" + query);
search = query; search = query;
set(protocol, all); set(protocol, all);
} }

@ -128,10 +128,9 @@ public class FragmentAnswers extends FragmentBase {
public void onActivityCreated(@Nullable Bundle savedInstanceState) { public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) { if (savedInstanceState != null)
searching = savedInstanceState.getString("fair:searching"); searching = savedInstanceState.getString("fair:searching");
adapter.search(searching); adapter.search(searching);
}
DB db = DB.getInstance(getContext()); DB db = DB.getInstance(getContext());
db.answer().liveAnswers().observe(getViewLifecycleOwner(), new Observer<List<EntityAnswer>>() { db.answer().liveAnswers().observe(getViewLifecycleOwner(), new Observer<List<EntityAnswer>>() {
@ -164,8 +163,10 @@ public class FragmentAnswers extends FragmentBase {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(String newText) {
searching = newText; if (getView() != null) {
adapter.search(newText); searching = newText;
adapter.search(newText);
}
return true; return true;
} }

@ -92,10 +92,9 @@ public class FragmentContacts extends FragmentBase {
public void onActivityCreated(@Nullable Bundle savedInstanceState) { public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) { if (savedInstanceState != null)
searching = savedInstanceState.getString("fair:searching"); searching = savedInstanceState.getString("fair:searching");
adapter.search(searching); adapter.search(searching);
}
DB db = DB.getInstance(getContext()); DB db = DB.getInstance(getContext());
db.contact().liveContacts().observe(getViewLifecycleOwner(), new Observer<List<TupleContactEx>>() { db.contact().liveContacts().observe(getViewLifecycleOwner(), new Observer<List<TupleContactEx>>() {
@ -130,8 +129,10 @@ public class FragmentContacts extends FragmentBase {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(String newText) {
searching = newText; if (getView() != null) {
adapter.search(newText); searching = newText;
adapter.search(newText);
}
return true; return true;
} }

@ -172,10 +172,9 @@ public class FragmentRules extends FragmentBase {
public void onActivityCreated(@Nullable Bundle savedInstanceState) { public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) { if (savedInstanceState != null)
searching = savedInstanceState.getString("fair:searching"); searching = savedInstanceState.getString("fair:searching");
adapter.search(searching); adapter.search(searching);
}
DB db = DB.getInstance(getContext()); DB db = DB.getInstance(getContext());
db.rule().liveRules(folder).observe(getViewLifecycleOwner(), new Observer<List<TupleRuleEx>>() { db.rule().liveRules(folder).observe(getViewLifecycleOwner(), new Observer<List<TupleRuleEx>>() {
@ -236,8 +235,10 @@ public class FragmentRules extends FragmentBase {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override @Override
public boolean onQueryTextChange(String newText) { public boolean onQueryTextChange(String newText) {
searching = newText; if (getView() != null) {
adapter.search(newText); searching = newText;
adapter.search(newText);
}
return true; return true;
} }

Loading…
Cancel
Save