package com.sketch.papertracingart.Utils;

import androidx.recyclerview.widget.DiffUtil;

import java.util.List;

public class DiffUtilUtils extends DiffUtil.Callback {

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

    public DiffUtilUtils(List<String> oldList, List<String> 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).equals(newList.get(newItemPosition));
    }

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