mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Merge pull request #996 from KingLucius/playFirstUnwatched
Set play button to first unwatched Episode on TV
This commit is contained in:
commit
fb89fd60b8
1 changed files with 10 additions and 7 deletions
|
@ -781,25 +781,28 @@ class ResultFragmentTv : Fragment() {
|
||||||
|
|
||||||
// resultEpisodeLoading.isVisible = episodes is Resource.Loading
|
// resultEpisodeLoading.isVisible = episodes is Resource.Loading
|
||||||
if (episodes is Resource.Success) {
|
if (episodes is Resource.Success) {
|
||||||
val first = episodes.value.firstOrNull()
|
|
||||||
if (first != null) {
|
val lastWatchedIndex = episodes.value.indexOfLast { ep -> ep.videoWatchState == VideoWatchState.Watched }
|
||||||
|
val firstUnwatched = episodes.value.getOrElse(lastWatchedIndex + 1) { episodes.value.firstOrNull() }
|
||||||
|
|
||||||
|
if (firstUnwatched != null) {
|
||||||
resultPlaySeriesText.text =
|
resultPlaySeriesText.text =
|
||||||
when {
|
when {
|
||||||
first.season != null ->
|
firstUnwatched.season != null ->
|
||||||
"${getString(R.string.season_short)}${first.season}:${getString(R.string.episode_short)}${first.episode}"
|
"${getString(R.string.season_short)}${firstUnwatched.season}:${getString(R.string.episode_short)}${firstUnwatched.episode}"
|
||||||
else -> "${getString(R.string.episode)} ${first.episode}"
|
else -> "${getString(R.string.episode)} ${firstUnwatched.episode}"
|
||||||
}
|
}
|
||||||
resultPlaySeriesButton.setOnClickListener {
|
resultPlaySeriesButton.setOnClickListener {
|
||||||
viewModel.handleAction(
|
viewModel.handleAction(
|
||||||
EpisodeClickEvent(
|
EpisodeClickEvent(
|
||||||
ACTION_CLICK_DEFAULT,
|
ACTION_CLICK_DEFAULT,
|
||||||
first
|
firstUnwatched
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
resultPlaySeriesButton.setOnLongClickListener {
|
resultPlaySeriesButton.setOnLongClickListener {
|
||||||
viewModel.handleAction(
|
viewModel.handleAction(
|
||||||
EpisodeClickEvent(ACTION_SHOW_OPTIONS, first)
|
EpisodeClickEvent(ACTION_SHOW_OPTIONS, firstUnwatched)
|
||||||
)
|
)
|
||||||
return@setOnLongClickListener true
|
return@setOnLongClickListener true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue