refactor: adjustments to updated tab extractor API
This commit is contained in:
parent
2c98d079de
commit
2c03ba204e
4 changed files with 36 additions and 35 deletions
|
|
@ -6,43 +6,43 @@ import android.content.SharedPreferences;
|
|||
import androidx.annotation.StringRes;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ChannelTabHandler.Tab;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ChannelTabs;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public final class ChannelTabs {
|
||||
private ChannelTabs() {
|
||||
public final class ChannelTabHelper {
|
||||
private ChannelTabHelper() {
|
||||
}
|
||||
|
||||
@StringRes
|
||||
private static int getShowTabKey(final Tab tab) {
|
||||
private static int getShowTabKey(final String tab) {
|
||||
switch (tab) {
|
||||
case Playlists:
|
||||
case ChannelTabs.PLAYLISTS:
|
||||
return R.string.show_channel_tabs_playlists;
|
||||
case Livestreams:
|
||||
case ChannelTabs.LIVESTREAMS:
|
||||
return R.string.show_channel_tabs_livestreams;
|
||||
case Shorts:
|
||||
case ChannelTabs.SHORTS:
|
||||
return R.string.show_channel_tabs_shorts;
|
||||
case Channels:
|
||||
case ChannelTabs.CHANNELS:
|
||||
return R.string.show_channel_tabs_channels;
|
||||
case Albums:
|
||||
case ChannelTabs.ALBUMS:
|
||||
return R.string.show_channel_tabs_albums;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@StringRes
|
||||
public static int getTranslationKey(final Tab tab) {
|
||||
public static int getTranslationKey(final String tab) {
|
||||
switch (tab) {
|
||||
case Playlists:
|
||||
case ChannelTabs.PLAYLISTS:
|
||||
return R.string.channel_tab_playlists;
|
||||
case Livestreams:
|
||||
case ChannelTabs.LIVESTREAMS:
|
||||
return R.string.channel_tab_livestreams;
|
||||
case Shorts:
|
||||
case ChannelTabs.SHORTS:
|
||||
return R.string.channel_tab_shorts;
|
||||
case Channels:
|
||||
case ChannelTabs.CHANNELS:
|
||||
return R.string.channel_tab_channels;
|
||||
case Albums:
|
||||
case ChannelTabs.ALBUMS:
|
||||
return R.string.channel_tab_albums;
|
||||
}
|
||||
return R.string.unknown_content;
|
||||
|
|
@ -62,8 +62,8 @@ public final class ChannelTabs {
|
|||
|
||||
public static boolean showChannelTab(final Context context,
|
||||
final SharedPreferences sharedPreferences,
|
||||
final Tab tab) {
|
||||
final int key = ChannelTabs.getShowTabKey(tab);
|
||||
final String tab) {
|
||||
final int key = ChannelTabHelper.getShowTabKey(tab);
|
||||
if (key == -1) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
|||
import org.schabi.newpipe.extractor.feed.FeedExtractor;
|
||||
import org.schabi.newpipe.extractor.feed.FeedInfo;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskInfo;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ChannelTabHandler;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
|
||||
import org.schabi.newpipe.extractor.search.SearchInfo;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||
|
|
@ -154,23 +154,23 @@ public final class ExtractorHelper {
|
|||
}
|
||||
|
||||
public static Single<ChannelTabInfo> 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<InfoItemsPage<InfoItem>> 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<CommentsInfo> getCommentsInfo(final int serviceId, final String url,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue