fix EpisodesListDialogFragment current episode selection

fix EpisodesListDialogFragment not selecting the correct episode, if the episode number doens't start at 0, if episodes are count across seasons
This commit is contained in:
2022-07-21 18:49:29 +02:00
parent 127bd030b9
commit 0028cb6dd7

View File

@ -51,8 +51,8 @@ class EpisodeListDialogFragment : DialogFragment() {
EpisodeItemAdapter.ViewType.PLAYER
)
// episodeNumber starts at 1, we need the episode index -> - 1
adapterRecEpisodes.currentSelected = model.currentEpisode.episodeNumber?.minus(1) ?: 0
// get the position/index of the currently playing episode
adapterRecEpisodes.currentSelected = model.episodes.items.indexOfFirst { it.id == model.currentEpisode.id }
binding.recyclerEpisodesPlayer.adapter = adapterRecEpisodes
binding.recyclerEpisodesPlayer.scrollToPosition(adapterRecEpisodes.currentSelected)