CymChad / BaseRecyclerViewAdapterHelper

BRVAH:Powerful and flexible RecyclerAdapter
http://www.recyclerview.org/
MIT License
24.2k stars 5.14k forks source link

4.0 onBindViewHolder中item可为空的问题 #3775

Closed ozy1996 closed 1 year ago

ozy1996 commented 1 year ago

protected abstract fun onBindViewHolder(holder: VH, position: Int, item: T?) 能否改成 protected abstract fun onBindViewHolder(holder: VH, position: Int, item: T),

像3.0版本那样protected abstract fun convert(holder: VH, item: T) 感觉没有必要设置可为空吧,要是真的有空值的话,在泛型中定义为空就好了吧,是在什么场景下会为null呢?

//这里定义String?可为null就好了吧~
class TestAdapter:BaseQuickAdapter<String?,QuickViewHolder>() {
    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: String?) {
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
       return QuickViewHolder(R.layout.listitem_title,parent)
    }
}
limuyang2 commented 1 year ago

pos数组越界的情况下,可能为null

limuyang2 commented 1 year ago

长时间未回复,问题先关闭了