package com.abbidot.tracker.adapter;

import android.content.Context;
import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

/**
 * Created  by .yzq on 2026/4/13/周一.
 *
 * @link
 * @description:
 */
public class TopSlideLayoutManager extends LinearLayoutManager {
    private int mTopOffset;

    public TopSlideLayoutManager(Context context, int orientation, boolean reverseLayout) {
        super(context, orientation, reverseLayout);
    }

    public void setTopOffset(int topOffset) {
        mTopOffset = topOffset;
        requestLayout();
    }

    @Override
    public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
        super.onLayoutChildren(recycler, state);
        // 可以在这里调整子项的位置，例如将顶部几个项上移
        if (getChildCount() > 0) {
            View firstChild = getChildAt(0);
            if (firstChild != null) {
                int top = getDecoratedTop(firstChild) - mTopOffset;
                layoutDecoratedWithMargins(firstChild, firstChild.getLeft(), top,
                        firstChild.getRight(), top + firstChild.getHeight());
            }
        }
    }
}

