|
|
@ -77,6 +77,7 @@ import ezvcard.property.FormattedName;
|
|
|
|
import ezvcard.property.RawProperty;
|
|
|
|
import ezvcard.property.RawProperty;
|
|
|
|
|
|
|
|
|
|
|
|
public class FragmentContacts extends FragmentBase {
|
|
|
|
public class FragmentContacts extends FragmentBase {
|
|
|
|
|
|
|
|
private View view;
|
|
|
|
private RecyclerView rvContacts;
|
|
|
|
private RecyclerView rvContacts;
|
|
|
|
private ContentLoadingProgressBar pbWait;
|
|
|
|
private ContentLoadingProgressBar pbWait;
|
|
|
|
private Group grpReady;
|
|
|
|
private Group grpReady;
|
|
|
@ -116,7 +117,7 @@ public class FragmentContacts extends FragmentBase {
|
|
|
|
setSubtitle(junk ? R.string.title_blocked_senders : R.string.menu_contacts);
|
|
|
|
setSubtitle(junk ? R.string.title_blocked_senders : R.string.menu_contacts);
|
|
|
|
setHasOptionsMenu(true);
|
|
|
|
setHasOptionsMenu(true);
|
|
|
|
|
|
|
|
|
|
|
|
View view = inflater.inflate(R.layout.fragment_contacts, container, false);
|
|
|
|
view = inflater.inflate(R.layout.fragment_contacts, container, false);
|
|
|
|
|
|
|
|
|
|
|
|
// Get controls
|
|
|
|
// Get controls
|
|
|
|
rvContacts = view.findViewById(R.id.rvContacts);
|
|
|
|
rvContacts = view.findViewById(R.id.rvContacts);
|
|
|
@ -206,15 +207,34 @@ public class FragmentContacts extends FragmentBase {
|
|
|
|
SearchView searchView = (SearchView) menuSearch.getActionView();
|
|
|
|
SearchView searchView = (SearchView) menuSearch.getActionView();
|
|
|
|
searchView.setQueryHint(getString(R.string.title_search));
|
|
|
|
searchView.setQueryHint(getString(R.string.title_search));
|
|
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(searching)) {
|
|
|
|
final String search = searching;
|
|
|
|
menuSearch.expandActionView();
|
|
|
|
view.post(new RunnableEx("contacts:search") {
|
|
|
|
searchView.setQuery(searching, true);
|
|
|
|
@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() {
|
|
|
|
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onQueryTextChange(String newText) {
|
|
|
|
public boolean onQueryTextChange(String newText) {
|
|
|
|
if (getView() != null && menuSearch.isActionViewExpanded()) {
|
|
|
|
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
|
|
|
searching = newText;
|
|
|
|
searching = newText;
|
|
|
|
adapter.search(newText);
|
|
|
|
adapter.search(newText);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -223,8 +243,10 @@ public class FragmentContacts extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean onQueryTextSubmit(String query) {
|
|
|
|
public boolean onQueryTextSubmit(String query) {
|
|
|
|
searching = query;
|
|
|
|
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
|
|
|
adapter.search(query);
|
|
|
|
searching = query;
|
|
|
|
|
|
|
|
adapter.search(query);
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|