|
|
|
@ -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)) {
|
|
|
|
|
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(searching, true);
|
|
|
|
|
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) {
|
|
|
|
|
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
|
|
|
|
searching = query;
|
|
|
|
|
adapter.search(query);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|