E - type of entity in the datasource.public abstract class SimpleDatasourcesDiffCallback<E> extends DiffCallback implements ParameterizedDiffCallback<E>
Datasources.| Constructor and Description |
|---|
SimpleDatasourcesDiffCallback(Datasource<? extends E> oldDatasource,
Datasource<? extends E> newDatasource) |
SimpleDatasourcesDiffCallback(Datasource<? extends E> oldDatasource,
Datasource<? extends E> newDatasource,
boolean shouldDetectMoves) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
areContentsTheSame(int oldItemPosition,
int newItemPosition) |
boolean |
areItemsTheSame(int oldItemPosition,
int newItemPosition) |
Object |
getChangePayload(E oldItem,
E newItem)
When
#areItemsTheSame(E, E) returns true for two items and
#areContentsTheSame(E, E) returns false for them, DiffUtil
calls this method to get a payload about the change. |
Object |
getChangePayload(int oldItemPosition,
int newItemPosition) |
int |
getNewListSize() |
int |
getOldListSize() |
shouldDetectMovesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitareContentsTheSame, areItemsTheSamepublic SimpleDatasourcesDiffCallback(@NonNull Datasource<? extends E> oldDatasource, @NonNull Datasource<? extends E> newDatasource)
public SimpleDatasourcesDiffCallback(@NonNull Datasource<? extends E> oldDatasource, @NonNull Datasource<? extends E> newDatasource, boolean shouldDetectMoves)
public int getOldListSize()
public int getNewListSize()
public final boolean areItemsTheSame(int oldItemPosition,
int newItemPosition)
public final boolean areContentsTheSame(int oldItemPosition,
int newItemPosition)
@Nullable public final Object getChangePayload(int oldItemPosition, int newItemPosition)
@Nullable public Object getChangePayload(@NonNull E oldItem, @NonNull E newItem)
#areItemsTheSame(E, E) returns true for two items and
#areContentsTheSame(E, E) returns false for them, DiffUtil
calls this method to get a payload about the change.
For example, if you are using DiffUtil with RecyclerView,
you can return the particular field that changed in the item and your
RecyclerView.ItemAnimator can use that
information to run the correct animation.
Default implementation returns null.
getChangePayload in interface ParameterizedDiffCallback<E>oldItem - The item in the old datasource.newItem - The item in the new datasource.