package com.gh.gamecenter.common.view.vertical_recycler

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.recyclerview.widget.RecyclerView

/**
 * 列表在滑动过程中拦截事件
 */
class CustomRecyclerView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
    RecyclerView(context, attrs) {

    override fun onInterceptTouchEvent(e: MotionEvent?): Boolean {
        if (isScrolling()) {
            return true
        }
        return super.onInterceptTouchEvent(e)
    }

    private fun isScrolling(): Boolean {
        return scrollState != SCROLL_STATE_IDLE
    }
}

