Skip to content

Instantly share code, notes, and snippets.

@florent37
Last active February 24, 2017 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save florent37/4bdcf9907d3a6deec420f7c660b8de18 to your computer and use it in GitHub Desktop.
Save florent37/4bdcf9907d3a6deec420f7c660b8de18 to your computer and use it in GitHub Desktop.
Recyclerview notify
protected void notifyChange(int oldCount, int newCount) {
if (newCount == oldCount) {
notifyItemRangeChanged(0, newCount);
} else if (newCount < oldCount) {
notifyItemRangeChanged(0, newCount);
notifyItemRangeRemoved(newCount, oldCount);
} else { //newCount > oldCount
notifyItemRangeChanged(0, oldCount);
notifyItemRangeInserted(oldCount + 1, newCount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment