Skip to content

Commit

Permalink
fix: notify data set changed using notifyDataSetChanged()
Browse files Browse the repository at this point in the history
Not sure why, but `notifyItemRangeRemoved()` & `notifyItemRangeInserted()` does not notify
the changes.

refs #1296
  • Loading branch information
goofyz committed Mar 28, 2024
1 parent 83a6fe8 commit 0f1ad69
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ class CandidateAdapter(theme: Theme) : RecyclerView.Adapter<CandidateAdapter.Vie
RIGHT,
}

@SuppressLint("NotifyDataSetChanged")
fun updateCandidates(candidates: List<CandidateListItem>) {
val prevSize = mCandidates.size
mCandidates.clear()
notifyItemRangeRemoved(0, prevSize)
mCandidates.addAll(candidates)
notifyItemRangeInserted(0, candidates.size)
notifyDataSetChanged()
}

override fun getItemCount(): Int {
Expand Down

0 comments on commit 0f1ad69

Please sign in to comment.