Skip to content

Commit 9118ecd

Browse files
committed
Remove unnecessary debug warning and use JDoc instead
1 parent 15fd47c commit 9118ecd

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -802,40 +802,42 @@ protected void doInitialLoadLogic() {
802802
// no-op
803803
}
804804

805-
private void search(final String theSearchString,
805+
/**
806+
* Perform a search.
807+
* @param theSearchString the trimmed search string
808+
* @param theContentFilter the content filter to use. FIXME: unused param
809+
* @param theSortFilter FIXME: unused param
810+
*/
811+
private void search(@NonNull final String theSearchString,
806812
final String[] theContentFilter,
807813
final String theSortFilter) {
808814
if (DEBUG) {
809815
Log.d(TAG, "search() called with: query = [" + theSearchString + "]");
810-
final String trimmedSearchString = theSearchString.trim();
811-
if (!trimmedSearchString.equals(theSearchString)) {
812-
Log.w(TAG, "The precondition is not satisfied. "
813-
+ "\"theSearchString\" is not allowed to have leading or trailing spaces");
814-
}
815816
}
816817
if (theSearchString.isEmpty()) {
817818
return;
818819
}
819820

821+
// Check if theSearchString is a URL which can be opened by NewPipe directly
822+
// and open it if possible.
820823
try {
821824
final StreamingService streamingService = NewPipe.getServiceByUrl(theSearchString);
822-
if (streamingService != null) {
823-
showLoading();
824-
disposables.add(Observable
825-
.fromCallable(() -> NavigationHelper.getIntentByLink(activity,
826-
streamingService, theSearchString))
827-
.subscribeOn(Schedulers.io())
828-
.observeOn(AndroidSchedulers.mainThread())
829-
.subscribe(intent -> {
830-
getFM().popBackStackImmediate();
831-
activity.startActivity(intent);
832-
}, throwable -> showTextError(getString(R.string.unsupported_url))));
833-
return;
834-
}
825+
showLoading();
826+
disposables.add(Observable
827+
.fromCallable(() -> NavigationHelper.getIntentByLink(activity,
828+
streamingService, theSearchString))
829+
.subscribeOn(Schedulers.io())
830+
.observeOn(AndroidSchedulers.mainThread())
831+
.subscribe(intent -> {
832+
getFM().popBackStackImmediate();
833+
activity.startActivity(intent);
834+
}, throwable -> showTextError(getString(R.string.unsupported_url))));
835+
return;
835836
} catch (final Exception ignored) {
836837
// Exception occurred, it's not a url
837838
}
838839

840+
// prepare search
839841
lastSearchedString = this.searchString;
840842
this.searchString = theSearchString;
841843
infoListAdapter.clearStreamItemList();
@@ -844,6 +846,7 @@ private void search(final String theSearchString,
844846
searchBinding.searchMetaInfoSeparator, disposables);
845847
hideKeyboardSearch();
846848

849+
// store search query if search history is enabled
847850
disposables.add(historyRecordManager.onSearched(serviceId, theSearchString)
848851
.observeOn(AndroidSchedulers.mainThread())
849852
.subscribe(
@@ -852,6 +855,8 @@ private void search(final String theSearchString,
852855
throwable -> showSnackBarError(new ErrorInfo(throwable, UserAction.SEARCHED,
853856
theSearchString, serviceId))
854857
));
858+
859+
// load search results
855860
suggestionPublisher.onNext(theSearchString);
856861
startLoading(false);
857862
}

0 commit comments

Comments
 (0)