mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-19 19:14:51 +00:00
removed additional hardcoding
This commit is contained in:
parent
ef284ba51d
commit
4cf3aabe89
3 changed files with 16 additions and 5 deletions
|
@ -95,8 +95,8 @@ class ChannelFragment : MainFragment() {
|
|||
_view = null
|
||||
}
|
||||
|
||||
fun selectTab(selectedTabIndex: Int) {
|
||||
_view?.selectTab(selectedTabIndex)
|
||||
fun selectTab(tab: ChannelTab) {
|
||||
_view?.selectTab(tab)
|
||||
}
|
||||
|
||||
@SuppressLint("ViewConstructor")
|
||||
|
@ -268,6 +268,10 @@ class ChannelFragment : MainFragment() {
|
|||
setLoading(true)
|
||||
}
|
||||
|
||||
fun selectTab(tab: ChannelTab) {
|
||||
(_viewPager.adapter as ChannelViewPagerAdapter).getTabPosition(tab)
|
||||
}
|
||||
|
||||
fun cleanup() {
|
||||
_taskLoadPolycentricProfile.cancel()
|
||||
_taskGetChannel.cancel()
|
||||
|
@ -560,18 +564,20 @@ class ChannelFragment : MainFragment() {
|
|||
(fragment as IChannelTabFragment).setPolycentricProfile(profile)
|
||||
}
|
||||
|
||||
val insertPosition = 2
|
||||
|
||||
//TODO only add channels and support if its setup on the polycentric profile
|
||||
if (profile != null && !(_viewPager.adapter as ChannelViewPagerAdapter).containsItem(
|
||||
ChannelTab.SUPPORT.ordinal.toLong()
|
||||
)
|
||||
) {
|
||||
(_viewPager.adapter as ChannelViewPagerAdapter).insert(2, ChannelTab.SUPPORT)
|
||||
(_viewPager.adapter as ChannelViewPagerAdapter).insert(insertPosition, ChannelTab.SUPPORT)
|
||||
}
|
||||
if (profile != null && !(_viewPager.adapter as ChannelViewPagerAdapter).containsItem(
|
||||
ChannelTab.CHANNELS.ordinal.toLong()
|
||||
)
|
||||
) {
|
||||
(_viewPager.adapter as ChannelViewPagerAdapter).insert(2, ChannelTab.CHANNELS)
|
||||
(_viewPager.adapter as ChannelViewPagerAdapter).insert(insertPosition, ChannelTab.CHANNELS)
|
||||
}
|
||||
(_viewPager.adapter as ChannelViewPagerAdapter).profile = profile
|
||||
_viewPager.adapter!!.notifyDataSetChanged()
|
||||
|
|
|
@ -41,6 +41,7 @@ import com.futo.platformplayer.states.StatePlatform
|
|||
import com.futo.platformplayer.states.StatePolycentric
|
||||
import com.futo.platformplayer.toHumanNowDiffString
|
||||
import com.futo.platformplayer.toHumanNumber
|
||||
import com.futo.platformplayer.views.adapters.ChannelTab
|
||||
import com.futo.platformplayer.views.adapters.feedtypes.PreviewPostView
|
||||
import com.futo.platformplayer.views.comments.AddCommentView
|
||||
import com.futo.platformplayer.views.others.CreatorThumbnail
|
||||
|
@ -264,7 +265,7 @@ class PostDetailFragment : MainFragment {
|
|||
|
||||
_buttonSupport.setOnClickListener {
|
||||
val author = _post?.author ?: _postOverview?.author;
|
||||
author?.let { _fragment.navigate<ChannelFragment>(it).selectTab(2); };
|
||||
author?.let { _fragment.navigate<ChannelFragment>(it).selectTab(ChannelTab.SUPPORT); };
|
||||
};
|
||||
|
||||
_buttonStore.setOnClickListener {
|
||||
|
|
|
@ -55,6 +55,10 @@ class ChannelViewPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifec
|
|||
return _supportedFragments.size
|
||||
}
|
||||
|
||||
fun getTabPosition(tab: ChannelTab): Int {
|
||||
return _tabs.indexOf(tab)
|
||||
}
|
||||
|
||||
fun getTabNames(tab: TabLayout.Tab, position: Int) {
|
||||
tab.text = _tabs[position].name
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue