Merge pull request #751 from Bnyro/master

chapter name clickable in portrait
This commit is contained in:
Bnyro 2022-07-10 18:14:30 +02:00 committed by GitHub
commit 988538662c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -262,9 +262,7 @@ class PlayerFragment : Fragment() {
// video description and chapters toggle // video description and chapters toggle
binding.playerTitleLayout.setOnClickListener { binding.playerTitleLayout.setOnClickListener {
binding.playerDescriptionArrow.animate().rotationBy(180F).setDuration(250).start() toggleDescription()
binding.descLinLayout.visibility =
if (binding.descLinLayout.isVisible) View.GONE else View.VISIBLE
} }
binding.commentsToggle.setOnClickListener { binding.commentsToggle.setOnClickListener {
@ -338,7 +336,6 @@ class PlayerFragment : Fragment() {
binding.linLayout.visibility = View.GONE binding.linLayout.visibility = View.GONE
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit) playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit)
playerBinding.exoTitle.visibility = View.VISIBLE playerBinding.exoTitle.visibility = View.VISIBLE
playerBinding.chapterLL.isClickable = true
val mainActivity = activity as MainActivity val mainActivity = activity as MainActivity
val fullscreenOrientationPref = PreferenceHelper val fullscreenOrientationPref = PreferenceHelper
@ -375,7 +372,6 @@ class PlayerFragment : Fragment() {
binding.linLayout.visibility = View.VISIBLE binding.linLayout.visibility = View.VISIBLE
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen) playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen)
playerBinding.exoTitle.visibility = View.INVISIBLE playerBinding.exoTitle.visibility = View.INVISIBLE
playerBinding.chapterLL.isClickable = false
scaleControls(1F) scaleControls(1F)
@ -390,6 +386,12 @@ class PlayerFragment : Fragment() {
playerBinding.exoPlayPause.scaleY = scaleFactor playerBinding.exoPlayPause.scaleY = scaleFactor
} }
private fun toggleDescription() {
binding.playerDescriptionArrow.animate().rotationBy(180F).setDuration(250).start()
binding.descLinLayout.visibility =
if (binding.descLinLayout.isVisible) View.GONE else View.VISIBLE
}
private fun toggleComments() { private fun toggleComments() {
binding.commentsRecView.visibility = binding.commentsRecView.visibility =
if (binding.commentsRecView.isVisible) View.GONE else View.VISIBLE if (binding.commentsRecView.isVisible) View.GONE else View.VISIBLE
@ -716,8 +718,6 @@ class PlayerFragment : Fragment() {
if (response.chapters != null) { if (response.chapters != null) {
chapters = response.chapters chapters = response.chapters
initializeChapters() initializeChapters()
// disabling chapterName click in portrait mode
playerBinding.chapterLL.isClickable = false
} }
// set default playback speed // set default playback speed
@ -1012,13 +1012,17 @@ class PlayerFragment : Fragment() {
} }
playerBinding.chapterLL.visibility = View.VISIBLE playerBinding.chapterLL.visibility = View.VISIBLE
playerBinding.chapterLL.setOnClickListener { playerBinding.chapterLL.setOnClickListener {
MaterialAlertDialogBuilder(requireContext()) if (isFullScreen) {
.setTitle(R.string.chapters) MaterialAlertDialogBuilder(requireContext())
.setItems(titles.toTypedArray()) { _, index -> .setTitle(R.string.chapters)
val position = chapters[index].start!! * 1000 .setItems(titles.toTypedArray()) { _, index ->
exoPlayer.seekTo(position) val position = chapters[index].start!! * 1000
} exoPlayer.seekTo(position)
.show() }
.show()
} else {
toggleDescription()
}
} }
setCurrentChapterName() setCurrentChapterName()
} }