use of org.wikipedia.search.SearchResults in project apps-android-wikipedia by wikimedia.
the class BottomContentView method requestReadMoreItems.
private void requestReadMoreItems(final HistoryEntry entry) {
if (entry == null || TextUtils.isEmpty(entry.getTitle().getPrefixedText())) {
hideReadMore();
return;
}
final long timeMillis = System.currentTimeMillis();
new FullTextSearchClient().requestMoreLike(entry.getTitle().getWikiSite(), entry.getTitle().getPrefixedText(), null, null, Constants.MAX_SUGGESTION_RESULTS * 2, new FullTextSearchClient.Callback() {
@Override
public void success(@NonNull Call<MwQueryResponse> call, @NonNull SearchResults results) {
funnel.setLatency(System.currentTimeMillis() - timeMillis);
readMoreItems = SearchResults.filter(results, entry.getTitle().getPrefixedText(), true);
if (!readMoreItems.getResults().isEmpty()) {
readMoreAdapter.setResults(results.getResults());
showReadMore();
} else {
// If there's no results, just hide the section
hideReadMore();
}
}
@Override
public void failure(@NonNull Call<MwQueryResponse> call, @NonNull Throwable caught) {
// Read More titles are expendable.
L.w("Error while fetching Read More titles.", caught);
}
});
}
Aggregations