1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package android.support.v7.util; 17 18/** 19 * An interface that can receive Update operations that are applied to a list. 20 * <p> 21 * This class can be used together with DiffUtil to detect changes between two lists. 22 */ 23public interface ListUpdateCallback { 24 /** 25 * Called when {@code count} number of items are inserted at the given position. 26 * 27 * @param position The position of the new item. 28 * @param count The number of items that have been added. 29 */ 30 void onInserted(int position, int count); 31 32 /** 33 * Called when {@code count} number of items are removed from the given position. 34 * 35 * @param position The position of the item which has been removed. 36 * @param count The number of items which have been removed. 37 */ 38 void onRemoved(int position, int count); 39 40 /** 41 * Called when an item changes its position in the list. 42 * 43 * @param fromPosition The previous position of the item before the move. 44 * @param toPosition The new position of the item. 45 */ 46 void onMoved(int fromPosition, int toPosition); 47 48 /** 49 * Called when {@code count} number of items are updated at the given position. 50 * 51 * @param position The position of the item which has been updated. 52 * @param count The number of items which has changed. 53 */ 54 void onChanged(int position, int count, Object payload); 55} 56