The google sample for a TODO app using MVVM, databinding, LiveData and notifyDataSetChanged(). I would like to replace this with DiffUtil. The sample reloads the data in the fragments onResume function.
Reloads the whole dataSet in onResume function.
@Override
public void onResume() {
    super.onResume();
    mTasksViewModel.start();
}
<ListView
    android:id="@+id/tasks_list"
    app:items="@{viewmodel.items}"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
public class TasksAdapter extends BaseAdapter {
    private final TasksViewModel mTasksViewModel;
    private List<Task> mTasks;
    private void setList(List<Task> tasks) {
        mTasks = tasks;
        notifyDataSetChanged();
    }
}
public class TasksListBindings {
    @SuppressWarnings("unchecked")
    @BindingAdapter("app:items")
    public static void setItems(ListView listView, List<Task> items) {
        TasksAdapter adapter = (TasksAdapter) listView.getAdapter();
        if (adapter != null)
        {
            adapter.setData(items);
        }
    }
}
I already implemented the DiffUtil as replacement of notifyDataSetChanged like this.
protected void setList(List<Item> tasks) {
    Log.d("customeee", "mTasks setList");
    final ItemsDiffCallback diffCallback = new ItemsDiffCallback(this.mTasks, tasks);
    final DiffUtil.DiffResult diffResult = DiffUtil.calculateDiff(diffCallback);
    diffResult.dispatchUpdatesTo(this);
    this.mTasks.clear();
    this.mTasks.addAll(tasks);
}
But what happens is no matter what I do the areContentsTheSame function is always returning true. If I force a false, the update is working just fine.
@Override
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
    final Item oldItem = mOldList.get(oldItemPosition);
    final Item newItem = mNewList.get(newItemPosition);
    Log.d("customeee", oldItem.getNote() + " newItem: "+newItem.getNote());
    Log.d("customeee", "New == old? "+mOldList.equals(mNewList));
    return oldItem.getNote().equals(newItem.getNote());
}
The oldItem.getNote() and newItem.getNote() are both returning the new value. I think this has something todo with the reference if the list object as oldList.equals(newList).
