@Test public void areItemsTheSame_ComparesModelIds() { boolean whenDifferentResult = callback.areItemsTheSame(0, 0); boolean whenSameResult = callback.areItemsTheSame(1, 1); assertThat(whenSameResult, is(true)); assertThat(whenDifferentResult, is(false)); }
@Override public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) { return mNewData.get(newItemPosition).getId().equals(mOldData.get(oldItemPosition).getId()); }
DefaultDiffCallback extends DiffUtil.Callback { @Override public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) { return mNewData.get(newItemPosition).getId().equals(mOldData.get(oldItemPosition).getId()); } }
DefaultDiffCallback extends DiffUtil.Callback { @Override public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) { return mNewData.get(newItemPosition).getId().equals(mOldData.get(oldItemPosition).getId()); } DefaultDiffCallback(@NonNull final List<D> oldData,
                               @NonNull final List<D> newData); }
DefaultDiffCallback extends DiffUtil.Callback { @Override public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) { return mNewData.get(newItemPosition).getId().equals(mOldData.get(oldItemPosition).getId()); } DefaultDiffCallback(@NonNull final List<D> oldData,
                               @NonNull final List<D> newData); @Override boolean areContentsTheSame(int oldItemPosition, int newItemPosition); @Override boolean areItemsTheSame(int oldItemPosition, int newItemPosition); @Override int getNewListSize(); @Override int getOldListSize(); @NonNull List<D> getOldData(); @NonNull List<D> getNewData(); }
DefaultDiffCallback extends DiffUtil.Callback { @Override public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) { return mNewData.get(newItemPosition).getId().equals(mOldData.get(oldItemPosition).getId()); } DefaultDiffCallback(@NonNull final List<D> oldData,
                               @NonNull final List<D> newData); @Override boolean areContentsTheSame(int oldItemPosition, int newItemPosition); @Override boolean areItemsTheSame(int oldItemPosition, int newItemPosition); @Override int getNewListSize(); @Override int getOldListSize(); @NonNull List<D> getOldData(); @NonNull List<D> getNewData();  }