Last active
February 24, 2017 15:48
-
-
Save florent37/4bdcf9907d3a6deec420f7c660b8de18 to your computer and use it in GitHub Desktop.
Recyclerview notify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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