Fix redundant hints on search screen (#7219)
On the search screen there was always the message "no results found" even before anything was ever searched and the message was repeated beneath it if really nothing was found by the app.
This commit is contained in:
parent
38f56d6d9b
commit
e2ff09bd34
|
@ -176,8 +176,7 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O
|
||||||
emptyViewHandler = new EmptyViewHandler(getContext());
|
emptyViewHandler = new EmptyViewHandler(getContext());
|
||||||
emptyViewHandler.attachToRecyclerView(recyclerView);
|
emptyViewHandler.attachToRecyclerView(recyclerView);
|
||||||
emptyViewHandler.setIcon(R.drawable.ic_search);
|
emptyViewHandler.setIcon(R.drawable.ic_search);
|
||||||
emptyViewHandler.setTitle(R.string.search_status_no_results);
|
emptyViewHandler.setTitle(R.string.type_to_search);
|
||||||
emptyViewHandler.setMessage(R.string.type_to_search);
|
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
|
|
||||||
chip = layout.findViewById(R.id.feed_title_chip);
|
chip = layout.findViewById(R.id.feed_title_chip);
|
||||||
|
@ -376,7 +375,7 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O
|
||||||
|
|
||||||
String query = searchView.getQuery().toString();
|
String query = searchView.getQuery().toString();
|
||||||
if (query.isEmpty()) {
|
if (query.isEmpty()) {
|
||||||
emptyViewHandler.setMessage(R.string.type_to_search);
|
emptyViewHandler.setTitle(R.string.type_to_search);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (feed != 0) {
|
if (feed != 0) {
|
||||||
|
@ -389,7 +388,7 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O
|
||||||
.subscribe(results -> {
|
.subscribe(results -> {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
adapterFeeds.updateData(results);
|
adapterFeeds.updateData(results);
|
||||||
emptyViewHandler.setMessage(getString(R.string.no_results_for_query, query));
|
emptyViewHandler.setTitle(getString(R.string.no_results_for_query, query));
|
||||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||||
}
|
}
|
||||||
disposableEpisodes = Observable.fromCallable(() -> DBReader.searchFeedItems(feed, query))
|
disposableEpisodes = Observable.fromCallable(() -> DBReader.searchFeedItems(feed, query))
|
||||||
|
@ -399,7 +398,7 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
this.results = results;
|
this.results = results;
|
||||||
adapter.updateItems(results);
|
adapter.updateItems(results);
|
||||||
emptyViewHandler.setMessage(getString(R.string.no_results_for_query, searchView.getQuery()));
|
emptyViewHandler.setTitle(getString(R.string.no_results_for_query, searchView.getQuery()));
|
||||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,10 @@ public class EmptyViewHandler {
|
||||||
tvTitle.setText(title);
|
tvTitle.setText(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
tvTitle.setText(title);
|
||||||
|
}
|
||||||
|
|
||||||
public void setMessage(int message) {
|
public void setMessage(int message) {
|
||||||
tvMessage.setText(message);
|
tvMessage.setText(message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue