Skip to content

Commit c1cef19

Browse files
authored
Merge pull request #12455 from TobiGr/nextPage-nullable
2 parents 0ef38e3 + 9ba3088 commit c1cef19

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,15 +1089,25 @@ private void handleSearchSuggestion() {
10891089
public void handleNextItems(final ListExtractor.InfoItemsPage<?> result) {
10901090
showListFooter(false);
10911091
infoListAdapter.addInfoItemList(result.getItems());
1092-
nextPage = result.getNextPage();
10931092

1094-
if (!result.getErrors().isEmpty() && nextPage != null) {
1095-
showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.SEARCHED,
1096-
"\"" + searchString + "\" → pageUrl: " + nextPage.getUrl() + ", "
1097-
+ "pageIds: " + nextPage.getIds() + ", "
1098-
+ "pageCookies: " + nextPage.getCookies(),
1099-
serviceId));
1093+
if (!result.getErrors().isEmpty()) {
1094+
// nextPage should be non-null at this point, because it refers to the page
1095+
// whose results are handled here, but let's check it anyway
1096+
if (nextPage == null) {
1097+
showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.SEARCHED,
1098+
"\"" + searchString + "\" → nextPage == null", serviceId));
1099+
} else {
1100+
showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.SEARCHED,
1101+
"\"" + searchString + "\" → pageUrl: " + nextPage.getUrl() + ", "
1102+
+ "pageIds: " + nextPage.getIds() + ", "
1103+
+ "pageCookies: " + nextPage.getCookies(),
1104+
serviceId));
1105+
}
11001106
}
1107+
1108+
// keep the reassignment of nextPage after the error handling to ensure that nextPage
1109+
// still holds the correct value during the error handling
1110+
nextPage = result.getNextPage();
11011111
super.handleNextItems(result);
11021112
}
11031113

0 commit comments

Comments
 (0)