don't show next ep button or autoplay if the current ep is the last ep
next_episode_id can be non null, even if it's the last episodepull/49/head
parent
aa41884db5
commit
287ef57bdb
|
@ -229,7 +229,7 @@ class PlayerActivity : AppCompatActivity() {
|
|||
else -> View.VISIBLE
|
||||
}
|
||||
|
||||
if (state == ExoPlayer.STATE_ENDED && model.currentEpisode.nextEpisodeId != null && Preferences.autoplay) {
|
||||
if (state == ExoPlayer.STATE_ENDED && hasNextEpisode() && Preferences.autoplay) {
|
||||
playNextEpisode()
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ class PlayerActivity : AppCompatActivity() {
|
|||
// if remaining time < 20 sec, a next ep is set, autoplay is enabled and not in pip:
|
||||
// show next ep button
|
||||
if (remainingTime in 1..20000) {
|
||||
if (!btnNextEpIsVisible && model.currentEpisode.nextEpisodeId != null && Preferences.autoplay && !isInPiPMode()) {
|
||||
if (!btnNextEpIsVisible && hasNextEpisode() && Preferences.autoplay && !isInPiPMode()) {
|
||||
showButtonNextEp()
|
||||
}
|
||||
} else if (btnNextEpIsVisible) {
|
||||
|
@ -358,12 +358,17 @@ class PlayerActivity : AppCompatActivity() {
|
|||
private fun onMediaChanged() {
|
||||
exo_text_title.text = model.getMediaTitle()
|
||||
|
||||
// hide the next ep button, if there is none
|
||||
button_next_ep_c.visibility = if (model.currentEpisode.nextEpisodeId == null) {
|
||||
View.GONE
|
||||
} else {
|
||||
View.VISIBLE
|
||||
}
|
||||
// hide the next episode button, if there is none
|
||||
button_next_ep_c.visibility = if (hasNextEpisode()) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current episode has a next episode.
|
||||
*
|
||||
* @return Boolean: true if there is a next episode, else false.
|
||||
*/
|
||||
private fun hasNextEpisode(): Boolean {
|
||||
return (model.currentEpisode.nextEpisodeId != null && !model.currentEpisodeIsLastEpisode())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -250,6 +250,15 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current episode is the last in the episodes list.
|
||||
*
|
||||
* @return Boolean: true if it is the last, else false.
|
||||
*/
|
||||
fun currentEpisodeIsLastEpisode(): Boolean {
|
||||
return episodes.items.lastOrNull()?.id == currentEpisode.id
|
||||
}
|
||||
|
||||
fun getEpisodeMetaByAoDMediaId(aodMediaId: Int): EpisodeMeta? {
|
||||
val meta = mediaMeta
|
||||
return if (meta is TVShowMeta) {
|
||||
|
|
Loading…
Reference in New Issue