Skip to content

Commit

Permalink
fix app crash for anime with a LOT of episodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmir1 committed May 30, 2021
1 parent a34dbf6 commit e388dc6
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,11 @@ class AnimeController :
val activity = activity ?: return
launchIO {
val episodeList = ArrayList<Episode>()
for (episodeItem in presenter.filteredAndSortedEpisodes.reversed()) {
val list = presenter.filteredAndSortedEpisodes.reversed()
val idx = list.indexOf(EpisodeItem(episode, anime!!))
val upper = if (list.lastIndex < idx + 100) list.lastIndex else idx + 100
val lower = if (0 > idx - 100) 0 else idx - 100
for (episodeItem in list.slice(lower..upper)) {
episodeList.add(episodeItem.episode)
}
val intent = WatcherActivity.newIntent(activity, presenter.anime, episode, episodeList)
Expand Down

0 comments on commit e388dc6

Please sign in to comment.