package com.offline.music.player.helper;

import androidx.recyclerview.widget.DiffUtil;

import com.offline.music.player.javabean.A_data.AudioItem;

import java.util.List;
import java.util.Objects;

public class AudioItemDiffCallback extends DiffUtil.Callback {

    private final List<AudioItem> oldList;
    private final List<AudioItem> newList;

    public AudioItemDiffCallback(List<AudioItem> oldList, List<AudioItem> 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) {
        return Objects.equals(oldList.get(oldItemPosition).getImage(), newList.get(newItemPosition).getImage());
    }

    @Override
    public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
        return oldList.get(oldItemPosition).equals(newList.get(newItemPosition));
    }
}

