fix possible and rare index out of bounds
This commit is contained in:
parent
9d698a974d
commit
09191f6732
|
@ -55,7 +55,8 @@ class EpisodeItemAdapter(private val episodes: List<Episode>) : RecyclerView.Ada
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateWatchedState(watched: Boolean, position: Int) {
|
fun updateWatchedState(watched: Boolean, position: Int) {
|
||||||
episodes[position].watched = watched
|
// use getOrNull as there could be a index out of bound when running this in onResume()
|
||||||
|
episodes.getOrNull(position)?.watched = watched
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class EpisodeViewHolder(val binding: ItemEpisodeBinding) : RecyclerView.ViewHolder(binding.root) {
|
inner class EpisodeViewHolder(val binding: ItemEpisodeBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||||
|
|
Loading…
Reference in New Issue