Remove unnecessary debug warning and use JDoc instead

This commit is contained in:
TobiGr 2023-08-17 16:51:31 +02:00
parent 15fd47c7f2
commit 9118ecd68f
1 changed files with 24 additions and 19 deletions

View File

@ -802,40 +802,42 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
// no-op // no-op
} }
private void search(final String theSearchString, /**
* Perform a search.
* @param theSearchString the trimmed search string
* @param theContentFilter the content filter to use. FIXME: unused param
* @param theSortFilter FIXME: unused param
*/
private void search(@NonNull final String theSearchString,
final String[] theContentFilter, final String[] theContentFilter,
final String theSortFilter) { final String theSortFilter) {
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "search() called with: query = [" + theSearchString + "]"); Log.d(TAG, "search() called with: query = [" + theSearchString + "]");
final String trimmedSearchString = theSearchString.trim();
if (!trimmedSearchString.equals(theSearchString)) {
Log.w(TAG, "The precondition is not satisfied. "
+ "\"theSearchString\" is not allowed to have leading or trailing spaces");
}
} }
if (theSearchString.isEmpty()) { if (theSearchString.isEmpty()) {
return; return;
} }
// Check if theSearchString is a URL which can be opened by NewPipe directly
// and open it if possible.
try { try {
final StreamingService streamingService = NewPipe.getServiceByUrl(theSearchString); final StreamingService streamingService = NewPipe.getServiceByUrl(theSearchString);
if (streamingService != null) { showLoading();
showLoading(); disposables.add(Observable
disposables.add(Observable .fromCallable(() -> NavigationHelper.getIntentByLink(activity,
.fromCallable(() -> NavigationHelper.getIntentByLink(activity, streamingService, theSearchString))
streamingService, theSearchString)) .subscribeOn(Schedulers.io())
.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread()) .subscribe(intent -> {
.subscribe(intent -> { getFM().popBackStackImmediate();
getFM().popBackStackImmediate(); activity.startActivity(intent);
activity.startActivity(intent); }, throwable -> showTextError(getString(R.string.unsupported_url))));
}, throwable -> showTextError(getString(R.string.unsupported_url)))); return;
return;
}
} catch (final Exception ignored) { } catch (final Exception ignored) {
// Exception occurred, it's not a url // Exception occurred, it's not a url
} }
// prepare search
lastSearchedString = this.searchString; lastSearchedString = this.searchString;
this.searchString = theSearchString; this.searchString = theSearchString;
infoListAdapter.clearStreamItemList(); infoListAdapter.clearStreamItemList();
@ -844,6 +846,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
searchBinding.searchMetaInfoSeparator, disposables); searchBinding.searchMetaInfoSeparator, disposables);
hideKeyboardSearch(); hideKeyboardSearch();
// store search query if search history is enabled
disposables.add(historyRecordManager.onSearched(serviceId, theSearchString) disposables.add(historyRecordManager.onSearched(serviceId, theSearchString)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe( .subscribe(
@ -852,6 +855,8 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
throwable -> showSnackBarError(new ErrorInfo(throwable, UserAction.SEARCHED, throwable -> showSnackBarError(new ErrorInfo(throwable, UserAction.SEARCHED,
theSearchString, serviceId)) theSearchString, serviceId))
)); ));
// load search results
suggestionPublisher.onNext(theSearchString); suggestionPublisher.onNext(theSearchString);
startLoading(false); startLoading(false);
} }