mirror of https://github.com/M66B/FairEmail.git
Cache search tab page titles
This commit is contained in:
parent
9aca7fde1d
commit
388bda791d
|
@ -215,6 +215,7 @@ public class FragmentOptions extends FragmentBase {
|
||||||
searchView.setOnSuggestionListener(onSuggestionListener);
|
searchView.setOnSuggestionListener(onSuggestionListener);
|
||||||
|
|
||||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||||
|
private String[] titles = null;
|
||||||
private View[] views = null;
|
private View[] views = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -239,18 +240,19 @@ public class FragmentOptions extends FragmentBase {
|
||||||
MatrixCursor cursor = new MatrixCursor(new String[]{"_id", "tab", "resid", "title"});
|
MatrixCursor cursor = new MatrixCursor(new String[]{"_id", "tab", "resid", "title"});
|
||||||
|
|
||||||
if (query != null && query.length() > 1) {
|
if (query != null && query.length() > 1) {
|
||||||
if (views == null) {
|
if (titles == null || views == null) {
|
||||||
|
titles = new String[TAB_PAGES.length];
|
||||||
views = new View[TAB_PAGES.length];
|
views = new View[TAB_PAGES.length];
|
||||||
LayoutInflater inflater = LayoutInflater.from(searchView.getContext());
|
LayoutInflater inflater = LayoutInflater.from(searchView.getContext());
|
||||||
for (int tab = 0; tab < TAB_PAGES.length; tab++)
|
for (int tab = 0; tab < TAB_PAGES.length; tab++) {
|
||||||
|
titles[tab] = (String) adapter.getPageTitle(tab);
|
||||||
views[tab] = inflater.inflate(TAB_PAGES[tab], null);
|
views[tab] = inflater.inflate(TAB_PAGES[tab], null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
for (int tab = 0; tab < TAB_PAGES.length; tab++) {
|
for (int tab = 0; tab < TAB_PAGES.length; tab++)
|
||||||
String title = (String) adapter.getPageTitle(tab);
|
id = getSuggestions(query.toLowerCase(), id, tab, titles[tab], views[tab], cursor);
|
||||||
id = getSuggestions(query.toLowerCase(), id, tab, title, views[tab], cursor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
searchView.setSuggestionsAdapter(new SimpleCursorAdapter(
|
searchView.setSuggestionsAdapter(new SimpleCursorAdapter(
|
||||||
|
|
Loading…
Reference in New Issue