Slide 13
Slide 13 text
@Nullable @Override
public Object getChangePayload(int oldItemPosition, int newItemPosition) {
Place newPlace = newItems.get(newItemPosition);
Place oldPlace = oldItems.get(oldItemPosition);
Bundle diffBundle = new Bundle();
if (newPlace.getDistance() != oldPlace.getDistance()) {
diffBundle.putInt(Place.KEY_DISTANCE, newPlace.getDistance());
}
if (!newPlace.getPrice().equals(oldPlace.getPrice())) {
diffBundle.putString(Place.KEY_PRICE, newPlace.getPrice());
}
if (!newPlace.getWaitingTime().equals(oldPlace.getWaitingTime())) {
diffBundle.putString(Place.KEY_WAITING_TIME, newPlace.getWaitingTime());
}
if (newPlace.hasFreeDelivery() != oldPlace.hasFreeDelivery()) {
diffBundle.putBoolean(Place.KEY_FREE_DELIVERY, newPlace.hasFreeDelivery());
}
return diffBundle.size() == 0 ? null : diffBundle;
}