package com.sound.prankparty.Utils;

import java.util.List;
import androidx.recyclerview.widget.DiffUtil;

import com.sound.prankparty.Room.FavoriteSounds;

public class FavoriteSoundsDiffCallback extends DiffUtil.Callback {
    private final List<FavoriteSounds> oldList;
    private final List<FavoriteSounds> newList;

    public FavoriteSoundsDiffCallback(List<FavoriteSounds> oldList, List<FavoriteSounds> newList) {
        this.oldList = oldList;
        this.newList = newList;
    }

    @Override
    public int getOldListSize() {
        return oldList.size();
    }

    @Override
    public int getNewListSize() {
        return newList.size();
    }

    @Override
    public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
        // 比较条目的唯一标识符，例如 ID
        return oldList.get(oldItemPosition).getPath() == newList.get(newItemPosition).getPath();
    }

    @Override
    public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
        // 比较条目的内容是否相同
        return oldList.get(oldItemPosition).equals(newList.get(newItemPosition));
    }
}

