@Test public void setAutoCompleteListView_shouldHideListViewWhenQueryLosesFocus() throws Exception { AutoCompleteListView listView = new AutoCompleteListView(ACTIVITY); listView.setVisibility(VISIBLE); peliasSearchView.setAutoCompleteListView(listView); AutoCompleteTextView queryText = getQueryTextView(); shadowOf(queryText).setViewFocus(false); assertThat(listView.getVisibility()).isEqualTo(GONE); }
public void setAutoCompleteListView(final ListView listView) { autoCompleteListView = listView; setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { PeliasSearchView.this.onFocusChange(view, hasFocus); } }); autoCompleteListView.setOnItemClickListener(new OnItemClickHandler().invoke()); autoCompleteListView.setOnScrollListener(new AbsListView.OnScrollListener() { int scrollState = SCROLL_STATE_IDLE; @Override public void onScrollStateChanged(AbsListView absListView, int i) { scrollState = i; } @Override public void onScroll(AbsListView absListView, int i, int i1, int i2) { if (dismissKeyboardOnListScroll && scrollState != SCROLL_STATE_IDLE && imeVisible) { if (searchSubmitListener != null) { checkHideAutocompleteList = true; } onFocusChange(PeliasSearchView.this, false); } } }); }
PeliasSearchView extends SearchView implements SearchView.OnQueryTextListener { public void setAutoCompleteListView(final ListView listView) { autoCompleteListView = listView; setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { PeliasSearchView.this.onFocusChange(view, hasFocus); } }); autoCompleteListView.setOnItemClickListener(new OnItemClickHandler().invoke()); autoCompleteListView.setOnScrollListener(new AbsListView.OnScrollListener() { int scrollState = SCROLL_STATE_IDLE; @Override public void onScrollStateChanged(AbsListView absListView, int i) { scrollState = i; } @Override public void onScroll(AbsListView absListView, int i, int i1, int i2) { if (dismissKeyboardOnListScroll && scrollState != SCROLL_STATE_IDLE && imeVisible) { if (searchSubmitListener != null) { checkHideAutocompleteList = true; } onFocusChange(PeliasSearchView.this, false); } } }); } }
PeliasSearchView extends SearchView implements SearchView.OnQueryTextListener { public void setAutoCompleteListView(final ListView listView) { autoCompleteListView = listView; setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { PeliasSearchView.this.onFocusChange(view, hasFocus); } }); autoCompleteListView.setOnItemClickListener(new OnItemClickHandler().invoke()); autoCompleteListView.setOnScrollListener(new AbsListView.OnScrollListener() { int scrollState = SCROLL_STATE_IDLE; @Override public void onScrollStateChanged(AbsListView absListView, int i) { scrollState = i; } @Override public void onScroll(AbsListView absListView, int i, int i1, int i2) { if (dismissKeyboardOnListScroll && scrollState != SCROLL_STATE_IDLE && imeVisible) { if (searchSubmitListener != null) { checkHideAutocompleteList = true; } onFocusChange(PeliasSearchView.this, false); } } }); } PeliasSearchView(Context context);  PeliasSearchView(Context context, AttributeSet attrs); }
PeliasSearchView extends SearchView implements SearchView.OnQueryTextListener { public void setAutoCompleteListView(final ListView listView) { autoCompleteListView = listView; setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { PeliasSearchView.this.onFocusChange(view, hasFocus); } }); autoCompleteListView.setOnItemClickListener(new OnItemClickHandler().invoke()); autoCompleteListView.setOnScrollListener(new AbsListView.OnScrollListener() { int scrollState = SCROLL_STATE_IDLE; @Override public void onScrollStateChanged(AbsListView absListView, int i) { scrollState = i; } @Override public void onScroll(AbsListView absListView, int i, int i1, int i2) { if (dismissKeyboardOnListScroll && scrollState != SCROLL_STATE_IDLE && imeVisible) { if (searchSubmitListener != null) { checkHideAutocompleteList = true; } onFocusChange(PeliasSearchView.this, false); } } }); } PeliasSearchView(Context context);  PeliasSearchView(Context context, AttributeSet attrs); void setSuggestFilter(SuggestFilter suggestFilter); void setAutoCompleteListView(final ListView listView); void disableAutoKeyboardShow(); void enableAutoKeyboardShow(); void setSearchSubmitListener(SearchSubmitListener listener); void setDismissKeyboardOnListScroll(boolean dismissOnScroll); @Override boolean onQueryTextSubmit(String query); @Override boolean onQueryTextChange(String text); void disableAutoComplete(); void setSavedSearch(SavedSearch savedSearch); void loadSavedSearches(); void setPelias(Pelias pelias); void setCallback(Callback<Result> callback); void setOnPeliasFocusChangeListener(OnFocusChangeListener onPeliasFocusChangeListener); void setOnSubmitListener(OnSubmitListener onSubmitListener); void setRecentSearchIconResourceId(int recentSearchIconResourceId); void setAutoCompleteIconResourceId(int autoCompleteIconResourceId); void setOnBackPressListener(OnBackPressListener onBackPressListener); void setCacheSearchResults(boolean cacheResults); boolean cacheSearchResults(); @Override void onActionViewCollapsed(); }
PeliasSearchView extends SearchView implements SearchView.OnQueryTextListener { public void setAutoCompleteListView(final ListView listView) { autoCompleteListView = listView; setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { PeliasSearchView.this.onFocusChange(view, hasFocus); } }); autoCompleteListView.setOnItemClickListener(new OnItemClickHandler().invoke()); autoCompleteListView.setOnScrollListener(new AbsListView.OnScrollListener() { int scrollState = SCROLL_STATE_IDLE; @Override public void onScrollStateChanged(AbsListView absListView, int i) { scrollState = i; } @Override public void onScroll(AbsListView absListView, int i, int i1, int i2) { if (dismissKeyboardOnListScroll && scrollState != SCROLL_STATE_IDLE && imeVisible) { if (searchSubmitListener != null) { checkHideAutocompleteList = true; } onFocusChange(PeliasSearchView.this, false); } } }); } PeliasSearchView(Context context);  PeliasSearchView(Context context, AttributeSet attrs); void setSuggestFilter(SuggestFilter suggestFilter); void setAutoCompleteListView(final ListView listView); void disableAutoKeyboardShow(); void enableAutoKeyboardShow(); void setSearchSubmitListener(SearchSubmitListener listener); void setDismissKeyboardOnListScroll(boolean dismissOnScroll); @Override boolean onQueryTextSubmit(String query); @Override boolean onQueryTextChange(String text); void disableAutoComplete(); void setSavedSearch(SavedSearch savedSearch); void loadSavedSearches(); void setPelias(Pelias pelias); void setCallback(Callback<Result> callback); void setOnPeliasFocusChangeListener(OnFocusChangeListener onPeliasFocusChangeListener); void setOnSubmitListener(OnSubmitListener onSubmitListener); void setRecentSearchIconResourceId(int recentSearchIconResourceId); void setAutoCompleteIconResourceId(int autoCompleteIconResourceId); void setOnBackPressListener(OnBackPressListener onBackPressListener); void setCacheSearchResults(boolean cacheResults); boolean cacheSearchResults(); @Override void onActionViewCollapsed(); static final String TAG; }