Fixed channel contents long press and fixed a crash due to time bars.

This commit is contained in:
Koen 2023-11-22 22:32:44 +01:00
parent b09d22e479
commit 5cafbf243e
4 changed files with 21 additions and 8 deletions

View File

@ -59,6 +59,7 @@ class ChannelContentsFragment : Fragment(), IChannelTabFragment {
val onChannelClicked = Event1<PlatformAuthorLink>(); val onChannelClicked = Event1<PlatformAuthorLink>();
val onAddToClicked = Event1<IPlatformContent>(); val onAddToClicked = Event1<IPlatformContent>();
val onAddToQueueClicked = Event1<IPlatformContent>(); val onAddToQueueClicked = Event1<IPlatformContent>();
val onLongPress = Event1<IPlatformContent>();
private fun getContentPager(channel: IPlatformChannel): IPager<IPlatformContent> { private fun getContentPager(channel: IPlatformChannel): IPager<IPlatformContent> {
Logger.i(TAG, "getContentPager"); Logger.i(TAG, "getContentPager");
@ -159,6 +160,7 @@ class ChannelContentsFragment : Fragment(), IChannelTabFragment {
this.onChannelClicked.subscribe(this@ChannelContentsFragment.onChannelClicked::emit); this.onChannelClicked.subscribe(this@ChannelContentsFragment.onChannelClicked::emit);
this.onAddToClicked.subscribe(this@ChannelContentsFragment.onAddToClicked::emit); this.onAddToClicked.subscribe(this@ChannelContentsFragment.onAddToClicked::emit);
this.onAddToQueueClicked.subscribe(this@ChannelContentsFragment.onAddToQueueClicked::emit); this.onAddToQueueClicked.subscribe(this@ChannelContentsFragment.onAddToQueueClicked::emit);
this.onLongPress.subscribe(this@ChannelContentsFragment.onLongPress::emit);
} }
_llmVideo = LinearLayoutManager(view.context); _llmVideo = LinearLayoutManager(view.context);

View File

@ -223,6 +223,12 @@ class ChannelFragment : MainFragment() {
else -> {}; else -> {};
} }
} }
adapter.onLongPress.subscribe { content ->
_overlayContainer.let {
if(content is IPlatformVideo)
_slideUpOverlay = UISlideOverlays.showVideoOptionsOverlay(content, it);
}
}
viewPager.adapter = adapter; viewPager.adapter = adapter;
val tabLayoutMediator = TabLayoutMediator(tabs, viewPager) { tab, position -> val tabLayoutMediator = TabLayoutMediator(tabs, viewPager) { tab, position ->

View File

@ -20,6 +20,7 @@ class ChannelViewPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifec
val onChannelClicked = Event1<PlatformAuthorLink>(); val onChannelClicked = Event1<PlatformAuthorLink>();
val onAddToClicked = Event1<IPlatformContent>(); val onAddToClicked = Event1<IPlatformContent>();
val onAddToQueueClicked = Event1<IPlatformContent>(); val onAddToQueueClicked = Event1<IPlatformContent>();
val onLongPress = Event1<IPlatformContent>();
override fun getItemCount(): Int { override fun getItemCount(): Int {
return _cache.size; return _cache.size;
@ -55,6 +56,7 @@ class ChannelViewPagerAdapter(fragmentManager: FragmentManager, lifecycle: Lifec
onChannelClicked.subscribe(this@ChannelViewPagerAdapter.onChannelClicked::emit); onChannelClicked.subscribe(this@ChannelViewPagerAdapter.onChannelClicked::emit);
onAddToClicked.subscribe(this@ChannelViewPagerAdapter.onAddToClicked::emit); onAddToClicked.subscribe(this@ChannelViewPagerAdapter.onAddToClicked::emit);
onAddToQueueClicked.subscribe(this@ChannelViewPagerAdapter.onAddToQueueClicked::emit); onAddToQueueClicked.subscribe(this@ChannelViewPagerAdapter.onAddToQueueClicked::emit);
onLongPress.subscribe(this@ChannelViewPagerAdapter.onLongPress::emit);
}; };
1 -> ChannelListFragment.newInstance().apply { onClickChannel.subscribe(onChannelClicked::emit) }; 1 -> ChannelListFragment.newInstance().apply { onClickChannel.subscribe(onChannelClicked::emit) };
//2 -> ChannelStoreFragment.newInstance(); //2 -> ChannelStoreFragment.newInstance();

View File

@ -69,7 +69,7 @@ open class PreviewVideoView : LinearLayout {
Logger.w(TAG, "Failed to load profile.", it); Logger.w(TAG, "Failed to load profile.", it);
}; };
private val _timeBar: ProgressBar; private val _timeBar: ProgressBar?;
val onVideoClicked = Event2<IPlatformVideo, Long>(); val onVideoClicked = Event2<IPlatformVideo, Long>();
val onLongPress = Event1<IPlatformVideo>(); val onLongPress = Event1<IPlatformVideo>();
@ -243,12 +243,15 @@ open class PreviewVideoView : LinearLayout {
_containerDuration.visibility = VISIBLE; _containerDuration.visibility = VISIBLE;
} }
if (shouldShowTimeBar) { val timeBar = _timeBar
val historyPosition = StatePlaylists.instance.getHistoryPosition(video.url) if (timeBar != null) {
_timeBar.visibility = if (historyPosition > 0) VISIBLE else GONE if (shouldShowTimeBar) {
_timeBar.progress = historyPosition.toFloat() / video.duration.toFloat() val historyPosition = StatePlaylists.instance.getHistoryPosition(video.url)
} else { timeBar.visibility = if (historyPosition > 0) VISIBLE else GONE
_timeBar.visibility = GONE timeBar.progress = historyPosition.toFloat() / video.duration.toFloat()
} else {
timeBar.visibility = GONE
}
} }
} }
else { else {
@ -256,7 +259,7 @@ open class PreviewVideoView : LinearLayout {
_imageVideo.setImageResource(0); _imageVideo.setImageResource(0);
_containerDuration.visibility = GONE; _containerDuration.visibility = GONE;
_containerLive.visibility = GONE; _containerLive.visibility = GONE;
_timeBar.visibility = GONE; _timeBar?.visibility = GONE;
} }
_textVideoMetadata.text = metadata + timeMeta; _textVideoMetadata.text = metadata + timeMeta;