Skip to content
Snippets Groups Projects
Verified Commit ef284ba5 authored by Kai DeLorenzo's avatar Kai DeLorenzo :purple_heart:
Browse files

fixed tab changing when adding the playlist tab

parent 5edd389e
No related branches found
No related tags found
1 merge request!18add support for channel playlists on the channel page
......@@ -459,17 +459,31 @@ class ChannelFragment : MainFragment() {
val supportsPlaylists =
StatePlatform.instance.getChannelClient(channel.url).capabilities.hasGetChannelPlaylists
val playlistPosition = 2
if (supportsPlaylists && !(_viewPager.adapter as ChannelViewPagerAdapter).containsItem(
ChannelTab.PLAYLISTS.ordinal.toLong()
)
) {
(_viewPager.adapter as ChannelViewPagerAdapter).insert(2, ChannelTab.PLAYLISTS)
// keep the current tab selected
if (_viewPager.currentItem >= playlistPosition) {
_viewPager.setCurrentItem(_viewPager.currentItem + 1, false)
}
(_viewPager.adapter as ChannelViewPagerAdapter).insert(
playlistPosition,
ChannelTab.PLAYLISTS
)
}
if (!supportsPlaylists && (_viewPager.adapter as ChannelViewPagerAdapter).containsItem(
ChannelTab.PLAYLISTS.ordinal.toLong()
)
) {
(_viewPager.adapter as ChannelViewPagerAdapter).remove(2)
// keep the current tab selected
if (_viewPager.currentItem >= playlistPosition) {
_viewPager.setCurrentItem(_viewPager.currentItem - 1, false)
}
(_viewPager.adapter as ChannelViewPagerAdapter).remove(playlistPosition)
}
// sets the channel for each tab
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment