mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20: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.AddToPlaylistDialog
|
||||||
import com.github.libretube.ui.dialogs.DownloadDialog
|
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.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.PlayerViewModel
|
import com.github.libretube.ui.models.PlayerViewModel
|
||||||
@ -953,19 +954,13 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// next and previous buttons
|
// next and previous buttons
|
||||||
playerBinding.skipPrev.visibility = if (
|
if (PlayerHelper.skipButtonsEnabled) {
|
||||||
PlayerHelper.skipButtonsEnabled && PlayingQueue.hasPrev()
|
playerBinding.skipPrev.setInvisible(!PlayingQueue.hasPrev())
|
||||||
) {
|
playerBinding.skipNext.setInvisible(!PlayingQueue.hasNext())
|
||||||
View.VISIBLE
|
|
||||||
} else {
|
|
||||||
View.INVISIBLE
|
|
||||||
}
|
}
|
||||||
playerBinding.skipNext.visibility =
|
|
||||||
if (PlayerHelper.skipButtonsEnabled) View.VISIBLE else View.INVISIBLE
|
|
||||||
|
|
||||||
playerBinding.skipPrev.setOnClickListener {
|
playerBinding.skipPrev.setOnClickListener {
|
||||||
videoId = PlayingQueue.getPrev()
|
playNextVideo(PlayingQueue.getPrev())
|
||||||
playVideo()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playerBinding.skipNext.setOnClickListener {
|
playerBinding.skipNext.setOnClickListener {
|
||||||
|
@ -45,12 +45,15 @@ object PlayingQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getPrev(): String? {
|
fun getPrev(): String? {
|
||||||
val index = queue.indexOf(currentStream)
|
return if (currentIndex() > 0) queue[currentIndex() - 1].url?.toID() else null
|
||||||
return if (index > 0) queue[index - 1].url?.toID() else null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasPrev(): Boolean {
|
fun hasPrev(): Boolean {
|
||||||
return queue.indexOf(currentStream) > 0
|
return currentIndex() > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hasNext(): Boolean {
|
||||||
|
return currentIndex() + 1 < size()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateCurrent(streamItem: StreamItem) {
|
fun updateCurrent(streamItem: StreamItem) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user