From 2c03ba204eabf505c9876945dcc3c95f54d8b786 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Sat, 5 Nov 2022 00:23:03 +0100 Subject: [PATCH] refactor: adjustments to updated tab extractor API --- .../list/channel/ChannelFragment.java | 15 ++++---- .../list/channel/ChannelTabFragment.java | 6 ++-- ...ChannelTabs.java => ChannelTabHelper.java} | 34 +++++++++---------- .../schabi/newpipe/util/ExtractorHelper.java | 16 ++++----- 4 files changed, 36 insertions(+), 35 deletions(-) rename app/src/main/java/org/schabi/newpipe/util/{ChannelTabs.java => ChannelTabHelper.java} (69%) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index d7955eb9d..322093781 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -26,12 +26,12 @@ import org.schabi.newpipe.error.ErrorInfo; import org.schabi.newpipe.error.UserAction; import org.schabi.newpipe.extractor.channel.ChannelInfo; import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException; -import org.schabi.newpipe.extractor.linkhandler.ChannelTabHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.fragments.BaseStateFragment; import org.schabi.newpipe.fragments.detail.TabAdapter; import org.schabi.newpipe.local.feed.notifications.NotificationHelper; import org.schabi.newpipe.local.subscription.SubscriptionManager; -import org.schabi.newpipe.util.ChannelTabs; +import org.schabi.newpipe.util.ChannelTabHelper; import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.NavigationHelper; @@ -281,17 +281,18 @@ public class ChannelFragment extends BaseStateFragment final SharedPreferences preferences = PreferenceManager .getDefaultSharedPreferences(context); - for (final ChannelTabHandler tab : currentInfo.getTabs()) { - if (ChannelTabs.showChannelTab(context, preferences, tab.getTab())) { + for (final ListLinkHandler linkHandler : currentInfo.getTabs()) { + final String tab = linkHandler.getContentFilters().get(0); + if (ChannelTabHelper.showChannelTab(context, preferences, tab)) { tabAdapter.addFragment( - ChannelTabFragment.getInstance(serviceId, tab), - context.getString(ChannelTabs.getTranslationKey(tab.getTab()))); + ChannelTabFragment.getInstance(serviceId, linkHandler), + context.getString(ChannelTabHelper.getTranslationKey(tab))); } } final String description = currentInfo.getDescription(); if (description != null && !description.isEmpty() - && ChannelTabs.showChannelTab( + && ChannelTabHelper.showChannelTab( context, preferences, R.string.show_channel_tabs_info)) { tabAdapter.addFragment( ChannelInfoFragment.getInstance(currentInfo), "Info"); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelTabFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelTabFragment.java index 1ce55df81..d00cb5cf9 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelTabFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelTabFragment.java @@ -13,7 +13,7 @@ import org.schabi.newpipe.error.UserAction; import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.channel.ChannelTabInfo; -import org.schabi.newpipe.extractor.linkhandler.ChannelTabHandler; +import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.fragments.list.BaseListInfoFragment; import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.ExtractorHelper; @@ -27,10 +27,10 @@ public class ChannelTabFragment extends BaseListInfoFragment getChannelTab(final int serviceId, - final ChannelTabHandler tabHandler, + final ListLinkHandler listLinkHandler, final boolean forceLoad) { checkServiceId(serviceId); return checkCache(forceLoad, serviceId, - tabHandler.getUrl() + "/" - + tabHandler.getTab().name(), InfoItem.InfoType.CHANNEL, + listLinkHandler.getUrl(), InfoItem.InfoType.CHANNEL, Single.fromCallable(() -> - ChannelTabInfo.getInfo(NewPipe.getService(serviceId), tabHandler))); + ChannelTabInfo.getInfo(NewPipe.getService(serviceId), listLinkHandler))); } public static Single> getMoreChannelTabItems(final int serviceId, - final ChannelTabHandler - tabHandler, + final ListLinkHandler + listLinkHandler, final Page nextPage) { checkServiceId(serviceId); return Single.fromCallable(() -> - ChannelTabInfo.getMoreItems(NewPipe.getService(serviceId), tabHandler, nextPage)); + ChannelTabInfo.getMoreItems(NewPipe.getService(serviceId), + listLinkHandler, nextPage)); } public static Single getCommentsInfo(final int serviceId, final String url,