mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
Merge pull request #4611 from Bnyro/master
fix: limit chapter bottom sheet to one instance
This commit is contained in:
commit
b72993cfee
@ -536,9 +536,9 @@ object PlayerHelper {
|
||||
return chapters
|
||||
.filter {
|
||||
it.highlightDrawable == null ||
|
||||
// remove the video highlight if it's already longer ago than [ChapterSegment.HIGHLIGHT_LENGTH],
|
||||
// otherwise the SponsorBlock highlight would be shown from its starting point to the end
|
||||
(currentPosition - it.start) < ChapterSegment.HIGHLIGHT_LENGTH
|
||||
// remove the video highlight if it's already longer ago than [ChapterSegment.HIGHLIGHT_LENGTH],
|
||||
// otherwise the SponsorBlock highlight would be shown from its starting point to the end
|
||||
(currentPosition - it.start) < ChapterSegment.HIGHLIGHT_LENGTH
|
||||
}
|
||||
.sortedBy { it.start }
|
||||
.indexOfLast { currentPosition >= it.start }
|
||||
|
@ -200,6 +200,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
.getInsetsController(mainActivity.window, mainActivity.window.decorView)
|
||||
|
||||
private var scrubbingTimeBar = false
|
||||
private var chaptersBottomSheet: ChaptersBottomSheet? = null
|
||||
|
||||
/**
|
||||
* Receiver for all actions in the PiP mode
|
||||
@ -772,8 +773,14 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
// enable the chapters dialog in the player
|
||||
playerBinding.chapterLL.setOnClickListener {
|
||||
updateMaxSheetHeight()
|
||||
ChaptersBottomSheet(chapters, exoPlayer)
|
||||
.show(childFragmentManager)
|
||||
val sheet = chaptersBottomSheet ?: ChaptersBottomSheet(chapters, exoPlayer).also {
|
||||
chaptersBottomSheet = it
|
||||
}
|
||||
if (sheet.isVisible) {
|
||||
sheet.dismiss()
|
||||
} else {
|
||||
sheet.show(childFragmentManager)
|
||||
}
|
||||
}
|
||||
|
||||
setCurrentChapterName()
|
||||
@ -822,6 +829,9 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
playVideo()
|
||||
// close comment bottom sheet for next video
|
||||
commentsViewModel.commentsSheetDismiss?.invoke()
|
||||
// kill the chapters bottom sheet
|
||||
chaptersBottomSheet?.dismiss()
|
||||
chaptersBottomSheet = null
|
||||
}
|
||||
|
||||
private fun prepareExoPlayerView() {
|
||||
|
@ -4,7 +4,6 @@ import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.media3.exoplayer.trackselection.TrackSelector
|
||||
|
Loading…
x
Reference in New Issue
Block a user