fixed +50 episodes selection

This commit is contained in:
LagradOst 2022-01-09 00:59:50 +01:00
parent e349339b5a
commit 487f6ea03a
2 changed files with 15 additions and 16 deletions

View file

@ -833,8 +833,7 @@ class ResultFragment : Fragment() {
}
ACTION_PLAY_EPISODE_IN_PLAYER -> {
currentEpisodes?.let { episodes ->
viewModel.getGenerator(episodes.indexOf(episodeClick.data))
viewModel.getGenerator(episodeClick.data)
?.let { generator ->
activity?.navigate(
R.id.global_to_navigation_player,
@ -844,7 +843,6 @@ class ResultFragment : Fragment() {
)
}
}
}
ACTION_RELOAD_EPISODE -> {
viewModel.loadEpisode(episodeClick.data, false)

View file

@ -190,12 +190,11 @@ class ResultViewModel : ViewModel() {
}
fun changeDubStatus(status: DubStatus?) {
if(status == null) return
dubSubEpisodes.value?.get(status)?.let { episodes ->
id.value?.let {
if (status != null) {
setDub(it, status)
}
}
_dubStatus.postValue(status)
updateEpisodes(null, episodes, null)
}
@ -207,7 +206,7 @@ class ResultViewModel : ViewModel() {
clearCache: Boolean = false
): Resource<Pair<Set<ExtractorLink>, Set<SubtitleData>>> {
return safeApiCall {
val index = _episodes.value?.indexOf(episode) ?: throw Exception("invalid Index")
val index = _episodes.value?.indexOf(episode) ?: episode.index
val currentLinks = mutableSetOf<ExtractorLink>()
val currentSubs = mutableSetOf<SubtitleData>()
@ -225,8 +224,10 @@ class ResultViewModel : ViewModel() {
}
}
fun getGenerator(episodeIndex: Int): IGenerator? {
generator?.goto(episodeIndex)
fun getGenerator(episode: ResultEpisode): IGenerator? {
val index = _episodes.value?.indexOf(episode) ?: episode.index
generator?.goto(index)
return generator
}