bgogetap / StickyHeaders

Easily add Sticky Headers to your RecyclerView
Apache License 2.0
521 stars 88 forks source link

Negative ViewHolder position #43

Closed ppamorim closed 7 years ago

ppamorim commented 7 years ago

Please add on readme to be careful of ViewHolder position, after an analyse of the source code, I discovered that the first header has a negative ID, this value can be a problem if you check it during the method onBindViewHolder, my code used to cancel the process if the ID is negative. I had problems to fill the copy header view and I solved it just treating this negative ID.

I was doing something like this:

override fun onBindViewHolder(holder: ViewHolder, position: Int) {

    if (holder.adapterPosition < 0) {
      return
    }

    //Continue binding the ViewHolder...
}

Thank you.

bgogetap commented 7 years ago

Why are you checking holder.adapterPosition? In onBindViewHolder You are given a new position for an item from your dataset to bind into the holder. That's all that matters.

bgogetap commented 7 years ago

Please reopen if you can expand on the issue.