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

removed hardcoding. fixed bugs. hide CHANNELS and SUPPORT for non polycentric linked channels

parent 1ccae849
No related branches found
No related tags found
1 merge request!18add support for channel playlists on the channel page
Showing with 517 additions and 493 deletions
......@@ -114,7 +114,7 @@ class ChannelAboutFragment : Fragment, IChannelTabFragment {
}
fun setPolycentricProfile(polycentricProfile: PolycentricProfile?) {
override fun setPolycentricProfile(polycentricProfile: PolycentricProfile?) {
_lastPolycentricProfile = polycentricProfile;
if (polycentricProfile == null) {
......
......@@ -309,7 +309,7 @@ class ChannelContentsFragment : Fragment(), IChannelTabFragment {
_adapterResults?.setLoading(loading);
}
fun setPolycentricProfile(polycentricProfile: PolycentricProfile?) {
override fun setPolycentricProfile(polycentricProfile: PolycentricProfile?) {
val p = _lastPolycentricProfile;
if (p != null && polycentricProfile != null && p.system == polycentricProfile.system) {
Logger.i(TAG, "setPolycentricProfile skipped because previous was same");
......
......@@ -124,7 +124,7 @@ class ChannelListFragment : Fragment, IChannelTabFragment {
}
}
fun setPolycentricProfile(polycentricProfile: PolycentricProfile?) {
override fun setPolycentricProfile(polycentricProfile: PolycentricProfile?) {
_taskLoadChannel.cancel();
_lastPolycentricProfile = polycentricProfile;
......
......@@ -46,7 +46,7 @@ class ChannelMonetizationFragment : Fragment, IChannelTabFragment {
_lastChannel = channel;
}
fun setPolycentricProfile(polycentricProfile: PolycentricProfile?) {
override fun setPolycentricProfile(polycentricProfile: PolycentricProfile?) {
_lastPolycentricProfile = polycentricProfile
if (polycentricProfile != null) {
_supportView?.setPolycentricProfile(polycentricProfile)
......
......@@ -15,6 +15,7 @@ import com.futo.platformplayer.api.media.models.PlatformAuthorLink
import com.futo.platformplayer.api.media.models.channels.IPlatformChannel
import com.futo.platformplayer.api.media.models.contents.ContentType
import com.futo.platformplayer.api.media.models.contents.IPlatformContent
import com.futo.platformplayer.api.media.models.playlists.IPlatformPlaylist
import com.futo.platformplayer.api.media.platforms.js.models.JSPager
import com.futo.platformplayer.api.media.structures.IAsyncPager
import com.futo.platformplayer.api.media.structures.IPager
......@@ -27,12 +28,8 @@ import com.futo.platformplayer.constructs.TaskHandler
import com.futo.platformplayer.engine.exceptions.PluginException
import com.futo.platformplayer.engine.exceptions.ScriptCaptchaRequiredException
import com.futo.platformplayer.exceptions.ChannelException
import com.futo.platformplayer.fragment.mainactivity.main.FeedView
import com.futo.platformplayer.fragment.mainactivity.main.PolycentricProfile
import com.futo.platformplayer.logging.Logger
import com.futo.platformplayer.states.StateCache
import com.futo.platformplayer.states.StatePlatform
import com.futo.platformplayer.states.StateSubscriptions
import com.futo.platformplayer.views.FeedStyle
import com.futo.platformplayer.views.adapters.ContentPreviewViewHolder
import com.futo.platformplayer.views.adapters.InsertedViewAdapterWithLoader
......@@ -42,15 +39,13 @@ import kotlinx.coroutines.launch
class ChannelPlaylistsFragment : Fragment(), IChannelTabFragment {
private var _recyclerResults: RecyclerView? = null
private var _llmVideo: LinearLayoutManager? = null
private var _llmPlaylist: LinearLayoutManager? = null
private var _loading = false
private var _pagerParent: IPager<IPlatformContent>? = null
private var _pager: IPager<IPlatformContent>? = null
private var _cache: FeedView.ItemCache<IPlatformContent>? = null
private var _pagerParent: IPager<IPlatformPlaylist>? = null
private var _pager: IPager<IPlatformPlaylist>? = null
private var _channel: IPlatformChannel? = null
private var _results: ArrayList<IPlatformContent> = arrayListOf()
private var _adapterResults: InsertedViewAdapterWithLoader<ContentPreviewViewHolder>? = null
private var _lastPolycentricProfile: PolycentricProfile? = null
val onContentClicked = Event2<IPlatformContent, Long>()
val onContentUrlClicked = Event2<String, ContentType>()
......@@ -61,62 +56,49 @@ class ChannelPlaylistsFragment : Fragment(), IChannelTabFragment {
val onAddToWatchLaterClicked = Event1<IPlatformContent>()
val onLongPress = Event1<IPlatformContent>()
private fun getPlaylistPager(channel: IPlatformChannel): IPager<IPlatformContent> {
private fun getPlaylistPager(channel: IPlatformChannel): IPager<IPlatformPlaylist> {
Logger.i(TAG, "getPlaylistPager")
return StatePlatform.instance.getChannelPlaylists(channel.url) as IPager<IPlatformContent>
return StatePlatform.instance.getChannelPlaylists(channel.url)
}
private val _taskLoadVideos =
TaskHandler<IPlatformChannel, IPager<IPlatformContent>>({ lifecycleScope }, {
private val _taskLoadPlaylists =
TaskHandler<IPlatformChannel, IPager<IPlatformPlaylist>>({ lifecycleScope }, {
val livePager = getPlaylistPager(it)
return@TaskHandler if (_channel?.let { channel ->
StateSubscriptions.instance.isSubscribed(
channel
)
} == true)
StateCache.cachePagerResults(lifecycleScope, livePager)
else livePager
return@TaskHandler livePager
}).success { livePager ->
setLoading(false)
setPager(livePager)
}
.exception<ScriptCaptchaRequiredException> { }
.exception<Throwable> {
Logger.w(TAG, "Failed to load initial videos.", it)
UIDialogs.showGeneralRetryErrorDialog(
requireContext(),
}.exception<ScriptCaptchaRequiredException> { }.exception<Throwable> {
Logger.w(TAG, "Failed to load initial playlists.", it)
UIDialogs.showGeneralRetryErrorDialog(requireContext(),
it.message ?: "",
it,
{ loadNextPage() })
}
private var _nextPageHandler: TaskHandler<IPager<IPlatformContent>, List<IPlatformContent>> =
TaskHandler<IPager<IPlatformContent>, List<IPlatformContent>>({ lifecycleScope }, {
if (it is IAsyncPager<*>)
it.nextPageAsync()
else
it.nextPage()
private var _nextPageHandler: TaskHandler<IPager<IPlatformPlaylist>, List<IPlatformPlaylist>> =
TaskHandler<IPager<IPlatformPlaylist>, List<IPlatformPlaylist>>({ lifecycleScope }, {
if (it is IAsyncPager<*>) it.nextPageAsync()
else it.nextPage()
processPagerExceptions(it)
return@TaskHandler it.getResults()
}).success {
setLoading(false)
val posBefore = _results.size
//val toAdd = it.filter { it is IPlatformVideo }.map { it as IPlatformVideo }
_results.addAll(it)
_adapterResults?.let { adapterVideo ->
adapterVideo.notifyItemRangeInserted(
adapterVideo.childToParentPosition(
_adapterResults?.let { adapterResult ->
adapterResult.notifyItemRangeInserted(
adapterResult.childToParentPosition(
posBefore
), it.size
)
}
}.exception<Throwable> {
Logger.w(TAG, "Failed to load next page.", it)
UIDialogs.showGeneralRetryErrorDialog(
requireContext(),
UIDialogs.showGeneralRetryErrorDialog(requireContext(),
it.message ?: "",
it,
{ loadNextPage() })
......@@ -127,10 +109,10 @@ class ChannelPlaylistsFragment : Fragment(), IChannelTabFragment {
super.onScrolled(recyclerView, dx, dy)
val recyclerResults = _recyclerResults ?: return
val llmVideo = _llmVideo ?: return
val llmPlaylist = _llmPlaylist ?: return
val visibleItemCount = recyclerResults.childCount
val firstVisibleItem = llmVideo.findFirstVisibleItemPosition()
val firstVisibleItem = llmPlaylist.findFirstVisibleItemPosition()
val visibleThreshold = 15
if (!_loading && firstVisibleItem + visibleItemCount + visibleThreshold >= _results.size) {
loadNextPage()
......@@ -147,7 +129,7 @@ class ChannelPlaylistsFragment : Fragment(), IChannelTabFragment {
Logger.i(TAG, "setChannel setChannel=${channel}")
_taskLoadVideos.cancel()
_taskLoadPlaylists.cancel()
_channel = channel
_results.clear()
......@@ -157,20 +139,14 @@ class ChannelPlaylistsFragment : Fragment(), IChannelTabFragment {
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_channel_videos, container, false)
_recyclerResults = view.findViewById(R.id.recycler_videos)
_adapterResults = PreviewContentListAdapter(
view.context,
FeedStyle.THUMBNAIL,
_results,
null,
Settings.instance.channel.progressBar
view.context, FeedStyle.THUMBNAIL, _results, null, Settings.instance.channel.progressBar
).apply {
this.onContentUrlClicked.subscribe(this@ChannelPlaylistsFragment.onContentUrlClicked::emit)
this.onUrlClicked.subscribe(this@ChannelPlaylistsFragment.onUrlClicked::emit)
......@@ -182,9 +158,9 @@ class ChannelPlaylistsFragment : Fragment(), IChannelTabFragment {
this.onLongPress.subscribe(this@ChannelPlaylistsFragment.onLongPress::emit)
}
_llmVideo = LinearLayoutManager(view.context)
_llmPlaylist = LinearLayoutManager(view.context)
_recyclerResults?.adapter = _adapterResults
_recyclerResults?.layoutManager = _llmVideo
_recyclerResults?.layoutManager = _llmPlaylist
_recyclerResults?.addOnScrollListener(_scrollListener)
return view
......@@ -196,31 +172,29 @@ class ChannelPlaylistsFragment : Fragment(), IChannelTabFragment {
_recyclerResults = null
_pager = null
_taskLoadVideos.cancel()
_taskLoadPlaylists.cancel()
_nextPageHandler.cancel()
}
private fun setPager(
pager: IPager<IPlatformContent>,
cache: FeedView.ItemCache<IPlatformContent>? = null
pager: IPager<IPlatformPlaylist>
) {
if (_pagerParent != null && _pagerParent is IRefreshPager<*>) {
(_pagerParent as IRefreshPager<*>).onPagerError.remove(this)
(_pagerParent as IRefreshPager<*>).onPagerChanged.remove(this)
_pagerParent = null
}
if (_pager is IReplacerPager<*>)
(_pager as IReplacerPager<*>).onReplaced.remove(this)
if (_pager is IReplacerPager<*>) (_pager as IReplacerPager<*>).onReplaced.remove(this)
val pagerToSet: IPager<IPlatformContent>?
val pagerToSet: IPager<IPlatformPlaylist>?
if (pager is IRefreshPager<*>) {
_pagerParent = pager
pagerToSet = pager.getCurrentPager() as IPager<IPlatformContent>
pagerToSet = pager.getCurrentPager() as IPager<IPlatformPlaylist>
pager.onPagerChanged.subscribe(this) {
lifecycleScope.launch(Dispatchers.Main) {
try {
loadPagerInternal(it as IPager<IPlatformContent>)
loadPagerInternal(it as IPager<IPlatformPlaylist>)
} catch (e: Throwable) {
Logger.e(TAG, "loadPagerInternal failed.", e)
}
......@@ -228,33 +202,26 @@ class ChannelPlaylistsFragment : Fragment(), IChannelTabFragment {
}
pager.onPagerError.subscribe(this) {
Logger.e(TAG, "Search pager failed: ${it.message}", it)
if (it is PluginException)
UIDialogs.toast("Plugin [${it.config.name}] failed due to:\n${it.message}")
else
UIDialogs.toast("Plugin failed due to:\n${it.message}")
if (it is PluginException) UIDialogs.toast("Plugin [${it.config.name}] failed due to:\n${it.message}")
else UIDialogs.toast("Plugin failed due to:\n${it.message}")
}
} else pagerToSet = pager
loadPagerInternal(pagerToSet, cache)
loadPagerInternal(pagerToSet)
}
private fun loadPagerInternal(
pager: IPager<IPlatformContent>,
cache: FeedView.ItemCache<IPlatformContent>? = null
pager: IPager<IPlatformPlaylist>
) {
_cache = cache
if (_pager is IReplacerPager<*>)
(_pager as IReplacerPager<*>).onReplaced.remove(this)
if (_pager is IReplacerPager<*>) (_pager as IReplacerPager<*>).onReplaced.remove(this)
if (pager is IReplacerPager<*>) {
pager.onReplaced.subscribe(this) { oldItem, newItem ->
if (_pager != pager)
return@subscribe
if (_pager != pager) return@subscribe
lifecycleScope.launch(Dispatchers.Main) {
val toReplaceIndex = _results.indexOfFirst { it == oldItem }
if (toReplaceIndex >= 0) {
_results[toReplaceIndex] = newItem as IPlatformContent
_results[toReplaceIndex] = newItem as IPlatformPlaylist
_adapterResults?.let {
it.notifyItemChanged(it.childToParentPosition(toReplaceIndex))
}
......@@ -277,11 +244,11 @@ class ChannelPlaylistsFragment : Fragment(), IChannelTabFragment {
private fun loadInitial() {
val channel: IPlatformChannel = _channel ?: return
setLoading(true)
_taskLoadVideos.run(channel)
_taskLoadPlaylists.run(channel)
}
private fun loadNextPage() {
val pager: IPager<IPlatformContent> = _pager ?: return
val pager: IPager<IPlatformPlaylist> = _pager ?: return
if (_pager?.hasMorePages() == true) {
setLoading(true)
_nextPageHandler.run(pager)
......@@ -293,32 +260,11 @@ class ChannelPlaylistsFragment : Fragment(), IChannelTabFragment {
_adapterResults?.setLoading(loading)
}
fun setPolycentricProfile(polycentricProfile: PolycentricProfile?) {
val p = _lastPolycentricProfile
if (p != null && polycentricProfile != null && p.system == polycentricProfile.system) {
Logger.i(
ChannelContentsFragment.TAG,
"setPolycentricProfile skipped because previous was same"
)
return
}
_lastPolycentricProfile = polycentricProfile
if (polycentricProfile != null) {
_taskLoadVideos.cancel()
val itemsRemoved = _results.size
_results.clear()
_adapterResults?.notifyItemRangeRemoved(0, itemsRemoved)
loadInitial()
}
}
private fun processPagerExceptions(pager: IPager<*>) {
if (pager is MultiPager<*> && pager.allowFailure) {
val ex = pager.getResultExceptions()
for (kv in ex) {
val jsVideoPager: JSPager<*>? = when (kv.key) {
val jsPager: JSPager<*>? = when (kv.key) {
is MultiPager<*> -> (kv.key as MultiPager<*>).findPager { it is JSPager<*> } as JSPager<*>?
is JSPager<*> -> kv.key as JSPager<*>
else -> null
......@@ -329,14 +275,12 @@ class ChannelPlaylistsFragment : Fragment(), IChannelTabFragment {
try {
val channel =
if (kv.value is ChannelException) (kv.value as ChannelException).channelNameOrUrl else null
if (jsVideoPager != null)
UIDialogs.toast(
it, "Plugin ${jsVideoPager.getPluginConfig().name} failed:\n" +
(if (!channel.isNullOrEmpty()) "(${channel}) " else "") +
"${kv.value.message}", false
)
else
UIDialogs.toast(it, kv.value.message ?: "", false)
if (jsPager != null) UIDialogs.toast(
it,
"Plugin ${jsPager.getPluginConfig().name} failed:\n" + (if (!channel.isNullOrEmpty()) "(${channel}) " else "") + "${kv.value.message}",
false
)
else UIDialogs.toast(it, kv.value.message ?: "", false)
} catch (e: Throwable) {
Logger.e(TAG, "Failed to show toast.", e)
}
......
package com.futo.platformplayer.fragment.channel.tab
import com.futo.platformplayer.api.media.models.channels.IPlatformChannel
import com.futo.platformplayer.fragment.mainactivity.main.PolycentricProfile
interface IChannelTabFragment {
fun setChannel(channel: IPlatformChannel);
}
\ No newline at end of file
fun setChannel(channel: IPlatformChannel)
fun setPolycentricProfile(polycentricProfile: PolycentricProfile?) {
}
}
......@@ -5,81 +5,117 @@ import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.futo.platformplayer.api.media.models.PlatformAuthorLink
import com.futo.platformplayer.api.media.models.channels.IPlatformChannel
import com.futo.platformplayer.api.media.models.contents.ContentType
import com.futo.platformplayer.api.media.models.contents.IPlatformContent
import com.futo.platformplayer.constructs.Event1
import com.futo.platformplayer.constructs.Event2
import com.futo.platformplayer.fragment.channel.tab.*
import com.futo.platformplayer.fragment.channel.tab.ChannelAboutFragment
import com.futo.platformplayer.fragment.channel.tab.ChannelContentsFragment
import com.futo.platformplayer.fragment.channel.tab.ChannelListFragment
import com.futo.platformplayer.fragment.channel.tab.ChannelMonetizationFragment
import com.futo.platformplayer.fragment.channel.tab.ChannelPlaylistsFragment
import com.futo.platformplayer.fragment.channel.tab.IChannelTabFragment
import com.futo.platformplayer.fragment.mainactivity.main.PolycentricProfile
import com.google.android.material.tabs.TabLayout
class ChannelViewPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) : FragmentStateAdapter(fragmentManager, lifecycle) {
private val _cache: Array<Fragment?> = arrayOfNulls(5);
val onContentUrlClicked = Event2<String, ContentType>();
val onUrlClicked = Event1<String>();
val onContentClicked = Event2<IPlatformContent, Long>();
val onChannelClicked = Event1<PlatformAuthorLink>();
val onAddToClicked = Event1<IPlatformContent>();
val onAddToQueueClicked = Event1<IPlatformContent>();
val onAddToWatchLaterClicked = Event1<IPlatformContent>();
val onLongPress = Event1<IPlatformContent>();
enum class ChannelTab {
VIDEOS, CHANNELS, PLAYLISTS, SUPPORT, ABOUT
}
class ChannelViewPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifecycle) :
FragmentStateAdapter(fragmentManager, lifecycle) {
private val _supportedFragments = mutableMapOf(
ChannelTab.VIDEOS.ordinal to ChannelTab.VIDEOS, ChannelTab.ABOUT.ordinal to ChannelTab.ABOUT
)
private val _tabs = arrayListOf(ChannelTab.VIDEOS, ChannelTab.ABOUT)
var profile: PolycentricProfile? = null
var channel: IPlatformChannel? = null
val onContentUrlClicked = Event2<String, ContentType>()
val onUrlClicked = Event1<String>()
val onContentClicked = Event2<IPlatformContent, Long>()
val onChannelClicked = Event1<PlatformAuthorLink>()
val onAddToClicked = Event1<IPlatformContent>()
val onAddToQueueClicked = Event1<IPlatformContent>()
val onAddToWatchLaterClicked = Event1<IPlatformContent>()
val onLongPress = Event1<IPlatformContent>()
override fun getItemId(position: Int): Long {
return _tabs[position].ordinal.toLong()
}
override fun containsItem(itemId: Long): Boolean {
return _supportedFragments.containsKey(itemId.toInt())
}
override fun getItemCount(): Int {
return _cache.size;
return _supportedFragments.size
}
fun getTabNames(tab: TabLayout.Tab, position: Int) {
tab.text = _tabs[position].name
}
fun insert(position: Int, tab: ChannelTab) {
_supportedFragments[tab.ordinal] = tab
_tabs.add(position, tab)
notifyItemInserted(position)
}
inline fun <reified T:IChannelTabFragment> getFragment(): T {
//TODO: I have a feeling this can somehow be synced with createFragment so only 1 mapping exists (without a Map<>)
if(T::class == ChannelContentsFragment::class)
return createFragment(0) as T;
else if(T::class == ChannelListFragment::class)
return createFragment(1) as T;
//else if(T::class == ChannelStoreFragment::class)
// return createFragment(2) as T;
else if(T::class == ChannelMonetizationFragment::class)
return createFragment(2) as T;
else if(T::class == ChannelAboutFragment::class)
return createFragment(3) as T;
else if(T::class == ChannelPlaylistsFragment::class)
return createFragment(4) as T;
else
throw NotImplementedError("Implement other types");
fun remove(position: Int) {
_supportedFragments.remove(_tabs[position].ordinal)
_tabs.removeAt(position)
notifyItemRemoved(position)
}
override fun createFragment(position: Int): Fragment {
val cachedFragment = _cache[position];
if (cachedFragment != null) {
return cachedFragment;
val fragment: Fragment
when (_tabs[position]) {
ChannelTab.VIDEOS -> {
fragment = ChannelContentsFragment.newInstance().apply {
onContentClicked.subscribe(this@ChannelViewPagerAdapter.onContentClicked::emit)
onContentUrlClicked.subscribe(this@ChannelViewPagerAdapter.onContentUrlClicked::emit)
onUrlClicked.subscribe(this@ChannelViewPagerAdapter.onUrlClicked::emit)
onChannelClicked.subscribe(this@ChannelViewPagerAdapter.onChannelClicked::emit)
onAddToClicked.subscribe(this@ChannelViewPagerAdapter.onAddToClicked::emit)
onAddToQueueClicked.subscribe(this@ChannelViewPagerAdapter.onAddToQueueClicked::emit)
onAddToWatchLaterClicked.subscribe(this@ChannelViewPagerAdapter.onAddToWatchLaterClicked::emit)
onLongPress.subscribe(this@ChannelViewPagerAdapter.onLongPress::emit)
}
}
ChannelTab.CHANNELS -> {
fragment = ChannelListFragment.newInstance()
.apply { onClickChannel.subscribe(onChannelClicked::emit) }
}
ChannelTab.PLAYLISTS -> {
fragment = ChannelPlaylistsFragment.newInstance().apply {
onContentClicked.subscribe(this@ChannelViewPagerAdapter.onContentClicked::emit)
onContentUrlClicked.subscribe(this@ChannelViewPagerAdapter.onContentUrlClicked::emit)
onUrlClicked.subscribe(this@ChannelViewPagerAdapter.onUrlClicked::emit)
onChannelClicked.subscribe(this@ChannelViewPagerAdapter.onChannelClicked::emit)
onAddToClicked.subscribe(this@ChannelViewPagerAdapter.onAddToClicked::emit)
onAddToQueueClicked.subscribe(this@ChannelViewPagerAdapter.onAddToQueueClicked::emit)
onAddToWatchLaterClicked.subscribe(this@ChannelViewPagerAdapter.onAddToWatchLaterClicked::emit)
onLongPress.subscribe(this@ChannelViewPagerAdapter.onLongPress::emit)
}
}
ChannelTab.SUPPORT -> {
fragment = ChannelMonetizationFragment.newInstance()
}
ChannelTab.ABOUT -> {
fragment = ChannelAboutFragment.newInstance()
}
}
channel?.let { (fragment as IChannelTabFragment).setChannel(it) }
profile?.let { (fragment as IChannelTabFragment).setPolycentricProfile(it) }
val fragment = when (position) {
0 -> ChannelContentsFragment.newInstance().apply {
onContentClicked.subscribe(this@ChannelViewPagerAdapter.onContentClicked::emit);
onContentUrlClicked.subscribe(this@ChannelViewPagerAdapter.onContentUrlClicked::emit);
onUrlClicked.subscribe(this@ChannelViewPagerAdapter.onUrlClicked::emit);
onChannelClicked.subscribe(this@ChannelViewPagerAdapter.onChannelClicked::emit);
onAddToClicked.subscribe(this@ChannelViewPagerAdapter.onAddToClicked::emit);
onAddToQueueClicked.subscribe(this@ChannelViewPagerAdapter.onAddToQueueClicked::emit);
onAddToWatchLaterClicked.subscribe(this@ChannelViewPagerAdapter.onAddToWatchLaterClicked::emit);
onLongPress.subscribe(this@ChannelViewPagerAdapter.onLongPress::emit);
};
1 -> ChannelListFragment.newInstance().apply { onClickChannel.subscribe(onChannelClicked::emit) };
//2 -> ChannelStoreFragment.newInstance();
2 -> ChannelMonetizationFragment.newInstance();
3 -> ChannelAboutFragment.newInstance();
4 -> ChannelPlaylistsFragment.newInstance().apply {
onContentClicked.subscribe(this@ChannelViewPagerAdapter.onContentClicked::emit);
onContentUrlClicked.subscribe(this@ChannelViewPagerAdapter.onContentUrlClicked::emit);
onUrlClicked.subscribe(this@ChannelViewPagerAdapter.onUrlClicked::emit);
onChannelClicked.subscribe(this@ChannelViewPagerAdapter.onChannelClicked::emit);
onAddToClicked.subscribe(this@ChannelViewPagerAdapter.onAddToClicked::emit);
onAddToQueueClicked.subscribe(this@ChannelViewPagerAdapter.onAddToQueueClicked::emit);
onAddToWatchLaterClicked.subscribe(this@ChannelViewPagerAdapter.onAddToWatchLaterClicked::emit);
onLongPress.subscribe(this@ChannelViewPagerAdapter.onLongPress::emit);
};
else -> throw IllegalStateException("Invalid tab position $position")
};
_cache[position]= fragment;
return fragment;
return fragment
}
}
\ No newline at end of file
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