Skip to content

Instantly share code, notes, and snippets.

@kmshack
Created April 6, 2017 01:52
Show Gist options
  • Save kmshack/e501d6c020c160adffe93e5d82b31dfb to your computer and use it in GitHub Desktop.
Save kmshack/e501d6c020c160adffe93e5d82b31dfb to your computer and use it in GitHub Desktop.
public class CustomRecyclerViewAdapter extends RecyclerView.Adapter<CustomRecyclerViewAdapter.ViewHolder> {
...
public void updateEmployeeListItems(List<Employee> employees) {
final EmployeeDiffCallback diffCallback = new EmployeeDiffCallback(this.mEmployees, employees);
final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(diffCallback);
this.mEmployees.clear();
this.mEmployees.addAll(employees);
diffResult.dispatchUpdatesTo(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment