code structure

This commit is contained in:
Bnyro 2022-08-08 17:05:18 +02:00
parent 27fcf05347
commit b0ca6baafd

View File

@ -177,6 +177,11 @@ class PlayerFragment : BaseFragment() {
*/ */
private lateinit var nowPlayingNotification: NowPlayingNotification private lateinit var nowPlayingNotification: NowPlayingNotification
/**
* history of played videos in the current lifecycle
*/
val videoIds = mutableListOf<String>()
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
arguments?.let { arguments?.let {
@ -752,6 +757,7 @@ class PlayerFragment : BaseFragment() {
} }
} }
} }
videoIds += videoId!!
} }
run() run()
} }
@ -1060,10 +1066,18 @@ class PlayerFragment : BaseFragment() {
} }
// next and previous buttons // next and previous buttons
playerBinding.next.visiblity = if (skipButtonsEnabled) View.VISIBLE else View.INVISIBLE playerBinding.skipPrev.visibility = if (
playerBinding.next.visibility = if (skipButtonsEnabled) View.VISIBLE else View.INVISIBLE skipButtonsEnabled && videoIds.indexOf(videoId!!) != 0
) View.VISIBLE else View.INVISIBLE
playerBinding.skipNext.visibility = if (skipButtonsEnabled) View.VISIBLE else View.INVISIBLE
playerBinding.next.setOnClickListener { playerBinding.skipPrev.setOnClickListener {
val index = videoIds.indexOf(videoId!!) - 1
videoId = videoIds[index]
playVideo()
}
playerBinding.skipNext.setOnClickListener {
playNextVideo() playNextVideo()
} }
} }