Skip to content

Commit

Permalink
Use notifyItemRangeChanged instead of notifyDataSetChanged in Pokemon…
Browse files Browse the repository at this point in the history
…Adapter
  • Loading branch information
skydoves committed Sep 1, 2020
1 parent 5040270 commit 21833a5
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ class PokemonAdapter : RecyclerView.Adapter<PokemonAdapter.PokemonViewHolder>()
}

fun addPokemonList(pokemonList: List<Pokemon>) {
val previous = items.size
items.addAll(pokemonList)
notifyDataSetChanged()
notifyItemRangeChanged(previous, pokemonList.size)
}

override fun onBindViewHolder(holder: PokemonViewHolder, position: Int) {
Expand Down

0 comments on commit 21833a5

Please sign in to comment.