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,17 +833,15 @@ class ResultFragment : Fragment() {
} }
ACTION_PLAY_EPISODE_IN_PLAYER -> { ACTION_PLAY_EPISODE_IN_PLAYER -> {
currentEpisodes?.let { episodes -> viewModel.getGenerator(episodeClick.data)
viewModel.getGenerator(episodes.indexOf(episodeClick.data)) ?.let { generator ->
?.let { generator -> activity?.navigate(
activity?.navigate( R.id.global_to_navigation_player,
R.id.global_to_navigation_player, GeneratorPlayer.newInstance(
GeneratorPlayer.newInstance( generator
generator
)
) )
} )
} }
} }
ACTION_RELOAD_EPISODE -> { ACTION_RELOAD_EPISODE -> {

View file

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