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