ListUpdateCallback.java revision a41c174e52ec211ef950259b274b120a705af438
1a41c174e52ec211ef950259b274b120a705af438Yigit Boyar/* 2a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * Copyright (C) 2016 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 */ 16a41c174e52ec211ef950259b274b120a705af438Yigit Boyarpackage android.support.v7.util; 17a41c174e52ec211ef950259b274b120a705af438Yigit Boyar 18a41c174e52ec211ef950259b274b120a705af438Yigit Boyar/** 19a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * An interface that can receive Update operations that are applied to a list. 20a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * <p> 21a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * This class can be used together with DiffUtil to detect changes between two lists. 22a41c174e52ec211ef950259b274b120a705af438Yigit Boyar */ 23a41c174e52ec211ef950259b274b120a705af438Yigit Boyarpublic interface ListUpdateCallback { 24a41c174e52ec211ef950259b274b120a705af438Yigit Boyar /** 25a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * Called when {@code count} number of items are inserted at the given position. 26a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * 27a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * @param position The position of the new item. 28a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * @param count The number of items that have been added. 29a41c174e52ec211ef950259b274b120a705af438Yigit Boyar */ 30a41c174e52ec211ef950259b274b120a705af438Yigit Boyar void onInserted(int position, int count); 31a41c174e52ec211ef950259b274b120a705af438Yigit Boyar 32a41c174e52ec211ef950259b274b120a705af438Yigit Boyar /** 33a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * Called when {@code count} number of items are removed from the given position. 34a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * 35a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * @param position The position of the item which has been removed. 36a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * @param count The number of items which have been removed. 37a41c174e52ec211ef950259b274b120a705af438Yigit Boyar */ 38a41c174e52ec211ef950259b274b120a705af438Yigit Boyar void onRemoved(int position, int count); 39a41c174e52ec211ef950259b274b120a705af438Yigit Boyar 40a41c174e52ec211ef950259b274b120a705af438Yigit Boyar /** 41a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * Called when an item changes its position in the list. 42a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * 43a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * @param fromPosition The previous position of the item before the move. 44a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * @param toPosition The new position of the item. 45a41c174e52ec211ef950259b274b120a705af438Yigit Boyar */ 46a41c174e52ec211ef950259b274b120a705af438Yigit Boyar void onMoved(int fromPosition, int toPosition); 47a41c174e52ec211ef950259b274b120a705af438Yigit Boyar 48a41c174e52ec211ef950259b274b120a705af438Yigit Boyar /** 49a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * Called when {@code count} number of items are updated at the given position. 50a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * 51a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * @param position The position of the item which has been updated. 52a41c174e52ec211ef950259b274b120a705af438Yigit Boyar * @param count The number of items which has changed. 53a41c174e52ec211ef950259b274b120a705af438Yigit Boyar */ 54a41c174e52ec211ef950259b274b120a705af438Yigit Boyar void onChanged(int position, int count, Object payload); 55a41c174e52ec211ef950259b274b120a705af438Yigit Boyar} 56