1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 00:20:32 +00:00

Fix NPE when ChannelTabLHFactory not implemented for a service

Fixes #10698
This commit is contained in:
TobiGr 2023-12-26 16:36:07 +01:00
parent 67629938d6
commit 0fa2e76c3e

View File

@ -17,6 +17,7 @@ import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabInfo; import org.schabi.newpipe.extractor.channel.tabs.ChannelTabInfo;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
import org.schabi.newpipe.extractor.linkhandler.ReadyChannelTabListLinkHandler; import org.schabi.newpipe.extractor.linkhandler.ReadyChannelTabListLinkHandler;
import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.fragments.list.BaseListInfoFragment; import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
@ -128,10 +129,13 @@ public class ChannelTabFragment extends BaseListInfoFragment<InfoItem, ChannelTa
// once `handleResult` is called, the parsed data was already saved to cache, so // once `handleResult` is called, the parsed data was already saved to cache, so
// we can discard any raw data in ReadyChannelTabListLinkHandler and create a // we can discard any raw data in ReadyChannelTabListLinkHandler and create a
// link handler with identical properties, but without any raw data // link handler with identical properties, but without any raw data
tabHandler = result.getService() final ListLinkHandlerFactory channelTabLHFactory = result.getService()
.getChannelTabLHFactory() .getChannelTabLHFactory();
.fromQuery(tabHandler.getId(), tabHandler.getContentFilters(), if (channelTabLHFactory != null) {
tabHandler.getSortFilter()); // some services do not not have a ChannelTabLHFactory
tabHandler = channelTabLHFactory.fromQuery(tabHandler.getId(),
tabHandler.getContentFilters(), tabHandler.getSortFilter());
}
} catch (final ParsingException e) { } catch (final ParsingException e) {
// silently ignore the error, as the app can continue to function normally // silently ignore the error, as the app can continue to function normally
Log.w(TAG, "Could not recreate channel tab handler", e); Log.w(TAG, "Could not recreate channel tab handler", e);