From 30e33d59e885195bbc67530c937371cfca41bef0 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Tue, 22 Jul 2025 16:03:37 +0200 Subject: [PATCH 1/2] Use correct fix for nextPage being null while creating error report in SearchFragment.handleNextItems() --- .../newpipe/fragments/list/search/SearchFragment.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index fc95312ea5a..6916ca82647 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -1089,8 +1089,9 @@ private void handleSearchSuggestion() { public void handleNextItems(final ListExtractor.InfoItemsPage result) { showListFooter(false); infoListAdapter.addInfoItemList(result.getItems()); - nextPage = result.getNextPage(); + // nextPage should not be null here because it refers to the page + // which results are handled here, but we check it anyway if (!result.getErrors().isEmpty() && nextPage != null) { showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.SEARCHED, "\"" + searchString + "\" → pageUrl: " + nextPage.getUrl() + ", " @@ -1098,6 +1099,10 @@ public void handleNextItems(final ListExtractor.InfoItemsPage result) { + "pageCookies: " + nextPage.getCookies(), serviceId)); } + + // keep the reassignment of nextPage after the error handling to ensure that nextPage + // still holds the correct value during the error handling + nextPage = result.getNextPage(); super.handleNextItems(result); } From 9ba30887f9f58f8cd545996a14e0117b815b68fc Mon Sep 17 00:00:00 2001 From: Stypox Date: Mon, 28 Jul 2025 14:43:46 +0200 Subject: [PATCH 2/2] Improve null checking further in SearchFragment.handleNextItems --- .../fragments/list/search/SearchFragment.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 6916ca82647..cea06b94288 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -1090,14 +1090,19 @@ public void handleNextItems(final ListExtractor.InfoItemsPage result) { showListFooter(false); infoListAdapter.addInfoItemList(result.getItems()); - // nextPage should not be null here because it refers to the page - // which results are handled here, but we check it anyway - if (!result.getErrors().isEmpty() && nextPage != null) { - showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.SEARCHED, - "\"" + searchString + "\" → pageUrl: " + nextPage.getUrl() + ", " - + "pageIds: " + nextPage.getIds() + ", " - + "pageCookies: " + nextPage.getCookies(), - serviceId)); + if (!result.getErrors().isEmpty()) { + // nextPage should be non-null at this point, because it refers to the page + // whose results are handled here, but let's check it anyway + if (nextPage == null) { + showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.SEARCHED, + "\"" + searchString + "\" → nextPage == null", serviceId)); + } else { + showSnackBarError(new ErrorInfo(result.getErrors(), UserAction.SEARCHED, + "\"" + searchString + "\" → pageUrl: " + nextPage.getUrl() + ", " + + "pageIds: " + nextPage.getIds() + ", " + + "pageCookies: " + nextPage.getCookies(), + serviceId)); + } } // keep the reassignment of nextPage after the error handling to ensure that nextPage