Fix visiblity of skip and prev btns when player locked

This commit is contained in:
Bnyro 2023-01-14 12:08:06 +01:00
parent 773a41d830
commit 1140c34d4d
2 changed files with 16 additions and 12 deletions

View File

@ -1,7 +0,0 @@
package com.github.libretube.ui.extensions
import android.view.View
fun View.setInvisible(value: Boolean) {
this.visibility = if (value) View.INVISIBLE else View.VISIBLE
}

View File

@ -75,7 +75,6 @@ import com.github.libretube.ui.dialogs.DownloadDialog
import com.github.libretube.ui.dialogs.ShareDialog import com.github.libretube.ui.dialogs.ShareDialog
import com.github.libretube.ui.extensions.setAspectRatio import com.github.libretube.ui.extensions.setAspectRatio
import com.github.libretube.ui.extensions.setFormattedHtml import com.github.libretube.ui.extensions.setFormattedHtml
import com.github.libretube.ui.extensions.setInvisible
import com.github.libretube.ui.extensions.setupSubscriptionButton import com.github.libretube.ui.extensions.setupSubscriptionButton
import com.github.libretube.ui.interfaces.OnlinePlayerOptions import com.github.libretube.ui.interfaces.OnlinePlayerOptions
import com.github.libretube.ui.models.CommentsViewModel import com.github.libretube.ui.models.CommentsViewModel
@ -1078,9 +1077,21 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
private fun syncQueueButtons() { private fun syncQueueButtons() {
if (!PlayerHelper.skipButtonsEnabled) return if (!PlayerHelper.skipButtonsEnabled) return
// next and previous buttons // toggle the visibility of next and prev buttons based on queue and whether the player view is locked
playerBinding.skipPrev.setInvisible(!PlayingQueue.hasPrev()) playerBinding.skipPrev.visibility = if (
playerBinding.skipNext.setInvisible(!PlayingQueue.hasNext()) PlayingQueue.hasPrev() && !binding.player.isPlayerLocked
) {
View.VISIBLE
} else {
View.INVISIBLE
}
playerBinding.skipNext.visibility = if (
PlayingQueue.hasNext() && !binding.player.isPlayerLocked
) {
View.VISIBLE
} else {
View.INVISIBLE
}
handler.postDelayed(this::syncQueueButtons, 100) handler.postDelayed(this::syncQueueButtons, 100)
} }
@ -1203,7 +1214,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
* Get all available player resolutions * Get all available player resolutions
*/ */
private fun getAvailableResolutions(): List<VideoResolution> { private fun getAvailableResolutions(): List<VideoResolution> {
val resolutions = exoPlayer.currentTracks.groups.map { group -> val resolutions = exoPlayer.currentTracks.groups.asSequence().map { group ->
(0 until group.length).map { (0 until group.length).map {
group.getTrackFormat(it).height group.getTrackFormat(it).height
} }