Improve search suggestion code
This commit is contained in:
parent
0711650ff8
commit
ccd82fb8b8
|
@ -119,7 +119,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
String lastSearchedString;
|
String lastSearchedString;
|
||||||
|
|
||||||
@State
|
@State
|
||||||
String searchSuggestionString;
|
String searchSuggestion;
|
||||||
|
|
||||||
@State
|
@State
|
||||||
boolean isCorrectedSearch;
|
boolean isCorrectedSearch;
|
||||||
|
@ -266,9 +266,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(searchSuggestionString)) {
|
handleSearchSuggestion();
|
||||||
handleSearchSuggestion(searchSuggestionString, isCorrectedSearch);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (suggestionDisposable == null || suggestionDisposable.isDisposed()) {
|
if (suggestionDisposable == null || suggestionDisposable.isDisposed()) {
|
||||||
initSuggestionObserver();
|
initSuggestionObserver();
|
||||||
|
@ -981,10 +979,11 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
NewPipe.getNameOfService(serviceId), searchString, 0);
|
NewPipe.getNameOfService(serviceId), searchString, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSearchSuggestion(result.getSearchSuggestion(), result.isCorrectedSearch());
|
searchSuggestion = result.getSearchSuggestion();
|
||||||
|
|
||||||
searchSuggestionString = result.getSearchSuggestion();
|
|
||||||
isCorrectedSearch = result.isCorrectedSearch();
|
isCorrectedSearch = result.isCorrectedSearch();
|
||||||
|
|
||||||
|
handleSearchSuggestion();
|
||||||
|
|
||||||
lastSearchedString = searchString;
|
lastSearchedString = searchString;
|
||||||
nextPageUrl = result.getNextPageUrl();
|
nextPageUrl = result.getNextPageUrl();
|
||||||
currentPageUrl = result.getUrl();
|
currentPageUrl = result.getUrl();
|
||||||
|
@ -1002,10 +1001,9 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
super.handleResult(result);
|
super.handleResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSearchSuggestion(@NonNull final String searchSuggestion,
|
private void handleSearchSuggestion() {
|
||||||
@NonNull final Boolean isCorrected) {
|
|
||||||
if (!TextUtils.isEmpty(searchSuggestion)) {
|
if (!TextUtils.isEmpty(searchSuggestion)) {
|
||||||
String helperText = getString(isCorrected
|
final String helperText = getString(isCorrectedSearch
|
||||||
? R.string.search_showing_result_for
|
? R.string.search_showing_result_for
|
||||||
: R.string.did_you_mean);
|
: R.string.did_you_mean);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue