package com.adealink.weparty.commonui.recycleview.diffutil

import androidx.recyclerview.widget.RecyclerView
import com.adealink.frame.log.Log

/**
 * 用于调试 DiffUtils 的结果, 跟踪数据的变化.
 * Created by XiaoDongLin.
 * Date: 2025/4/8
 */
private const val TAG = "DiffDebugLog"

class DiffDebugLogger : RecyclerView.AdapterDataObserver() {
    override fun onChanged() {
        Log.d(TAG, "onChanged")
    }

    override fun onItemRangeChanged(positionStart: Int, itemCount: Int) {
        Log.d(TAG, "onItemChanged: positionStart = $positionStart, itemCount=$itemCount")
    }

    override fun onItemRangeChanged(positionStart: Int, itemCount: Int, payload: Any?) {
        Log.d(TAG, "onItemChangedPayload: positionStart = $positionStart, itemCount=$itemCount")
    }

    override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
        Log.d(TAG, "onItemRangeInserted: positionStart = $positionStart, itemCount=$itemCount")
    }

    override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
        Log.d(TAG, "onItemRangeRemoved: positionStart = $positionStart, itemCount=$itemCount")
    }

    override fun onItemRangeMoved(fromPosition: Int, toPosition: Int, itemCount: Int) {
        Log.d(TAG, "onItemRangeMoved: $fromPosition --> $toPosition, itemCount=$itemCount")
    }
}