mirror of https://github.com/M66B/FairEmail.git
Fixed search interaction (2)
This commit is contained in:
parent
43dc9b9ff9
commit
434e755dce
|
@ -57,6 +57,7 @@ import java.util.Objects;
|
|||
public class FragmentAnswers extends FragmentBase {
|
||||
private boolean cards;
|
||||
|
||||
private View view;
|
||||
private RecyclerView rvAnswer;
|
||||
private ContentLoadingProgressBar pbWait;
|
||||
private Group grpReady;
|
||||
|
@ -79,7 +80,7 @@ public class FragmentAnswers extends FragmentBase {
|
|||
setSubtitle(R.string.menu_answers);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
View view = inflater.inflate(R.layout.fragment_answers, container, false);
|
||||
view = inflater.inflate(R.layout.fragment_answers, container, false);
|
||||
|
||||
// Get controls
|
||||
rvAnswer = view.findViewById(R.id.rvAnswer);
|
||||
|
@ -228,15 +229,34 @@ public class FragmentAnswers extends FragmentBase {
|
|||
SearchView searchView = (SearchView) menuSearch.getActionView();
|
||||
searchView.setQueryHint(getString(R.string.title_rules_search_hint));
|
||||
|
||||
if (!TextUtils.isEmpty(searching)) {
|
||||
menuSearch.expandActionView();
|
||||
searchView.setQuery(searching, true);
|
||||
}
|
||||
final String search = searching;
|
||||
view.post(new RunnableEx("answers:search") {
|
||||
@Override
|
||||
public void delegate() {
|
||||
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
return;
|
||||
|
||||
if (TextUtils.isEmpty(search))
|
||||
menuSearch.collapseActionView();
|
||||
else {
|
||||
menuSearch.expandActionView();
|
||||
searchView.setQuery(search, 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 && menuSearch.isActionViewExpanded()) {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
searching = newText;
|
||||
adapter.search(newText);
|
||||
}
|
||||
|
@ -245,8 +265,10 @@ public class FragmentAnswers extends FragmentBase {
|
|||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
searching = query;
|
||||
adapter.search(query);
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
searching = query;
|
||||
adapter.search(query);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -77,6 +77,7 @@ import ezvcard.property.FormattedName;
|
|||
import ezvcard.property.RawProperty;
|
||||
|
||||
public class FragmentContacts extends FragmentBase {
|
||||
private View view;
|
||||
private RecyclerView rvContacts;
|
||||
private ContentLoadingProgressBar pbWait;
|
||||
private Group grpReady;
|
||||
|
@ -116,7 +117,7 @@ public class FragmentContacts extends FragmentBase {
|
|||
setSubtitle(junk ? R.string.title_blocked_senders : R.string.menu_contacts);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
View view = inflater.inflate(R.layout.fragment_contacts, container, false);
|
||||
view = inflater.inflate(R.layout.fragment_contacts, container, false);
|
||||
|
||||
// Get controls
|
||||
rvContacts = view.findViewById(R.id.rvContacts);
|
||||
|
@ -206,15 +207,34 @@ public class FragmentContacts extends FragmentBase {
|
|||
SearchView searchView = (SearchView) menuSearch.getActionView();
|
||||
searchView.setQueryHint(getString(R.string.title_search));
|
||||
|
||||
if (!TextUtils.isEmpty(searching)) {
|
||||
menuSearch.expandActionView();
|
||||
searchView.setQuery(searching, true);
|
||||
}
|
||||
final String search = searching;
|
||||
view.post(new RunnableEx("contacts:search") {
|
||||
@Override
|
||||
public void delegate() {
|
||||
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
return;
|
||||
|
||||
if (TextUtils.isEmpty(search))
|
||||
menuSearch.collapseActionView();
|
||||
else {
|
||||
menuSearch.expandActionView();
|
||||
searchView.setQuery(search, 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 && menuSearch.isActionViewExpanded()) {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
searching = newText;
|
||||
adapter.search(newText);
|
||||
}
|
||||
|
@ -223,8 +243,10 @@ public class FragmentContacts extends FragmentBase {
|
|||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
searching = query;
|
||||
adapter.search(query);
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
searching = query;
|
||||
adapter.search(query);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -604,17 +604,34 @@ public class FragmentFolders extends FragmentBase {
|
|||
SearchView searchView = (SearchView) menuSearch.getActionView();
|
||||
searchView.setQueryHint(getString(R.string.title_search));
|
||||
|
||||
if (TextUtils.isEmpty(searching))
|
||||
menuSearch.collapseActionView();
|
||||
else {
|
||||
menuSearch.expandActionView();
|
||||
searchView.setQuery(searching, true);
|
||||
}
|
||||
final String search = searching;
|
||||
view.post(new RunnableEx("folders:search") {
|
||||
@Override
|
||||
public void delegate() {
|
||||
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
return;
|
||||
|
||||
if (TextUtils.isEmpty(search))
|
||||
menuSearch.collapseActionView();
|
||||
else {
|
||||
menuSearch.expandActionView();
|
||||
searchView.setQuery(search, 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 && menuSearch.isActionViewExpanded()) {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
searching = newText;
|
||||
adapter.search(newText);
|
||||
}
|
||||
|
@ -623,8 +640,10 @@ public class FragmentFolders extends FragmentBase {
|
|||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
searching = query;
|
||||
adapter.search(query);
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
searching = query;
|
||||
adapter.search(query);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -75,6 +75,7 @@ public class FragmentRules extends FragmentBase {
|
|||
|
||||
private boolean cards;
|
||||
|
||||
private View view;
|
||||
private RecyclerView rvRule;
|
||||
private ContentLoadingProgressBar pbWait;
|
||||
private Group grpReady;
|
||||
|
@ -109,7 +110,7 @@ public class FragmentRules extends FragmentBase {
|
|||
setSubtitle(R.string.title_edit_rules);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
View view = inflater.inflate(R.layout.fragment_rules, container, false);
|
||||
view = inflater.inflate(R.layout.fragment_rules, container, false);
|
||||
|
||||
// Get controls
|
||||
rvRule = view.findViewById(R.id.rvRule);
|
||||
|
@ -223,15 +224,34 @@ public class FragmentRules extends FragmentBase {
|
|||
SearchView searchView = (SearchView) menuSearch.getActionView();
|
||||
searchView.setQueryHint(getString(R.string.title_rules_search_hint));
|
||||
|
||||
if (!TextUtils.isEmpty(searching)) {
|
||||
menuSearch.expandActionView();
|
||||
searchView.setQuery(searching, true);
|
||||
}
|
||||
final String search = searching;
|
||||
view.post(new RunnableEx("rules:search") {
|
||||
@Override
|
||||
public void delegate() {
|
||||
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
|
||||
return;
|
||||
|
||||
if (TextUtils.isEmpty(search))
|
||||
menuSearch.collapseActionView();
|
||||
else {
|
||||
menuSearch.expandActionView();
|
||||
searchView.setQuery(search, 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 && menuSearch.isActionViewExpanded()) {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
searching = newText;
|
||||
adapter.search(newText);
|
||||
}
|
||||
|
@ -240,8 +260,10 @@ public class FragmentRules extends FragmentBase {
|
|||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
searching = query;
|
||||
adapter.search(query);
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
searching = query;
|
||||
adapter.search(query);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue