mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-19 19:14:51 +00:00
fixed tab changing when adding the playlist tab
This commit is contained in:
parent
5edd389e84
commit
ef284ba51d
1 changed files with 16 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue