mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Merge pull request #2033 from Bnyro/prev-btn
Fix the next video button at the player
This commit is contained in:
commit
cd43760352
@ -0,0 +1,7 @@
|
||||
package com.github.libretube.ui.extensions
|
||||
|
||||
import android.view.View
|
||||
|
||||
fun View.setInvisible(value: Boolean) {
|
||||
this.visibility = if (value) View.INVISIBLE else View.VISIBLE
|
||||
}
|
@ -72,6 +72,7 @@ import com.github.libretube.ui.base.BaseFragment
|
||||
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
|
||||
import com.github.libretube.ui.dialogs.DownloadDialog
|
||||
import com.github.libretube.ui.dialogs.ShareDialog
|
||||
import com.github.libretube.ui.extensions.setInvisible
|
||||
import com.github.libretube.ui.extensions.setupSubscriptionButton
|
||||
import com.github.libretube.ui.interfaces.OnlinePlayerOptions
|
||||
import com.github.libretube.ui.models.PlayerViewModel
|
||||
@ -953,19 +954,13 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
||||
}
|
||||
|
||||
// next and previous buttons
|
||||
playerBinding.skipPrev.visibility = if (
|
||||
PlayerHelper.skipButtonsEnabled && PlayingQueue.hasPrev()
|
||||
) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.INVISIBLE
|
||||
if (PlayerHelper.skipButtonsEnabled) {
|
||||
playerBinding.skipPrev.setInvisible(!PlayingQueue.hasPrev())
|
||||
playerBinding.skipNext.setInvisible(!PlayingQueue.hasNext())
|
||||
}
|
||||
playerBinding.skipNext.visibility =
|
||||
if (PlayerHelper.skipButtonsEnabled) View.VISIBLE else View.INVISIBLE
|
||||
|
||||
playerBinding.skipPrev.setOnClickListener {
|
||||
videoId = PlayingQueue.getPrev()
|
||||
playVideo()
|
||||
playNextVideo(PlayingQueue.getPrev())
|
||||
}
|
||||
|
||||
playerBinding.skipNext.setOnClickListener {
|
||||
|
@ -45,12 +45,15 @@ object PlayingQueue {
|
||||
}
|
||||
|
||||
fun getPrev(): String? {
|
||||
val index = queue.indexOf(currentStream)
|
||||
return if (index > 0) queue[index - 1].url?.toID() else null
|
||||
return if (currentIndex() > 0) queue[currentIndex() - 1].url?.toID() else null
|
||||
}
|
||||
|
||||
fun hasPrev(): Boolean {
|
||||
return queue.indexOf(currentStream) > 0
|
||||
return currentIndex() > 0
|
||||
}
|
||||
|
||||
fun hasNext(): Boolean {
|
||||
return currentIndex() + 1 < size()
|
||||
}
|
||||
|
||||
fun updateCurrent(streamItem: StreamItem) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user