mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-02 22:30:40 +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 =
|
val supportsPlaylists =
|
||||||
StatePlatform.instance.getChannelClient(channel.url).capabilities.hasGetChannelPlaylists
|
StatePlatform.instance.getChannelClient(channel.url).capabilities.hasGetChannelPlaylists
|
||||||
|
val playlistPosition = 2
|
||||||
if (supportsPlaylists && !(_viewPager.adapter as ChannelViewPagerAdapter).containsItem(
|
if (supportsPlaylists && !(_viewPager.adapter as ChannelViewPagerAdapter).containsItem(
|
||||||
ChannelTab.PLAYLISTS.ordinal.toLong()
|
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(
|
if (!supportsPlaylists && (_viewPager.adapter as ChannelViewPagerAdapter).containsItem(
|
||||||
ChannelTab.PLAYLISTS.ordinal.toLong()
|
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
|
// sets the channel for each tab
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue