public interface

ListUpdateCallback

 androidx.recyclerview.widget.ListUpdateCallback

Subclasses:

BatchingListUpdateCallback, SortedListAdapterCallback<T2>, AdapterListUpdateCallback, SortedList.Callback<T2>, SortedList.BatchedCallback<T2>

Gradle dependencies

compile group: 'androidx.recyclerview', name: 'recyclerview', version: '1.3.0-alpha02'

  • groupId: androidx.recyclerview
  • artifactId: recyclerview
  • version: 1.3.0-alpha02

Artifact androidx.recyclerview:recyclerview:1.3.0-alpha02 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.recyclerview:recyclerview com.android.support:recyclerview-v7

Androidx class mapping:

androidx.recyclerview.widget.ListUpdateCallback android.support.v7.util.ListUpdateCallback

Overview

An interface that can receive Update operations that are applied to a list.

This class can be used together with DiffUtil to detect changes between two lists.

Summary

Methods
public voidonChanged(int position, int count, java.lang.Object payload)

Called when count number of items are updated at the given position.

public voidonInserted(int position, int count)

Called when count number of items are inserted at the given position.

public voidonMoved(int fromPosition, int toPosition)

Called when an item changes its position in the list.

public voidonRemoved(int position, int count)

Called when count number of items are removed from the given position.

Methods

public void onInserted(int position, int count)

Called when count number of items are inserted at the given position.

Parameters:

position: The position of the new item.
count: The number of items that have been added.

public void onRemoved(int position, int count)

Called when count number of items are removed from the given position.

Parameters:

position: The position of the item which has been removed.
count: The number of items which have been removed.

public void onMoved(int fromPosition, int toPosition)

Called when an item changes its position in the list.

Parameters:

fromPosition: The previous position of the item before the move.
toPosition: The new position of the item.

public void onChanged(int position, int count, java.lang.Object payload)

Called when count number of items are updated at the given position.

Parameters:

position: The position of the item which has been updated.
count: The number of items which has changed.

Source

/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package androidx.recyclerview.widget;

import androidx.annotation.Nullable;

/**
 * An interface that can receive Update operations that are applied to a list.
 * <p>
 * This class can be used together with DiffUtil to detect changes between two lists.
 */
public interface ListUpdateCallback {
    /**
     * Called when {@code count} number of items are inserted at the given position.
     *
     * @param position The position of the new item.
     * @param count    The number of items that have been added.
     */
    void onInserted(int position, int count);

    /**
     * Called when {@code count} number of items are removed from the given position.
     *
     * @param position The position of the item which has been removed.
     * @param count    The number of items which have been removed.
     */
    void onRemoved(int position, int count);

    /**
     * Called when an item changes its position in the list.
     *
     * @param fromPosition The previous position of the item before the move.
     * @param toPosition   The new position of the item.
     */
    void onMoved(int fromPosition, int toPosition);

    /**
     * Called when {@code count} number of items are updated at the given position.
     *
     * @param position The position of the item which has been updated.
     * @param count    The number of items which has changed.
     */
    void onChanged(int position, int count, @Nullable Object payload);
}