Skip to content

Commit 0fa2e76

Browse files
committed
Fix NPE when ChannelTabLHFactory not implemented for a service
Fixes #10698
1 parent 6762993 commit 0fa2e76

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelTabFragment.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabInfo;
1818
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1919
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
20+
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
2021
import org.schabi.newpipe.extractor.linkhandler.ReadyChannelTabListLinkHandler;
2122
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
2223
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
@@ -128,10 +129,13 @@ public void handleResult(@NonNull final ChannelTabInfo result) {
128129
// once `handleResult` is called, the parsed data was already saved to cache, so
129130
// we can discard any raw data in ReadyChannelTabListLinkHandler and create a
130131
// link handler with identical properties, but without any raw data
131-
tabHandler = result.getService()
132-
.getChannelTabLHFactory()
133-
.fromQuery(tabHandler.getId(), tabHandler.getContentFilters(),
134-
tabHandler.getSortFilter());
132+
final ListLinkHandlerFactory channelTabLHFactory = result.getService()
133+
.getChannelTabLHFactory();
134+
if (channelTabLHFactory != null) {
135+
// some services do not not have a ChannelTabLHFactory
136+
tabHandler = channelTabLHFactory.fromQuery(tabHandler.getId(),
137+
tabHandler.getContentFilters(), tabHandler.getSortFilter());
138+
}
135139
} catch (final ParsingException e) {
136140
// silently ignore the error, as the app can continue to function normally
137141
Log.w(TAG, "Could not recreate channel tab handler", e);

0 commit comments

Comments
 (0)