pull/32/head
parent
dc4a9df268
commit
317df0dd55
@ -0,0 +1,30 @@ |
|||||||
|
package io.legado.app.help |
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView |
||||||
|
|
||||||
|
internal class AdapterDataObserverProxy(var adapterDataObserver: RecyclerView.AdapterDataObserver, var headerCount: Int) : RecyclerView.AdapterDataObserver() { |
||||||
|
override fun onChanged() { |
||||||
|
adapterDataObserver.onChanged() |
||||||
|
} |
||||||
|
|
||||||
|
override fun onItemRangeChanged(positionStart: Int, itemCount: Int) { |
||||||
|
adapterDataObserver.onItemRangeChanged(positionStart + headerCount, itemCount) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onItemRangeChanged(positionStart: Int, itemCount: Int, payload: Any?) { |
||||||
|
adapterDataObserver.onItemRangeChanged(positionStart + headerCount, itemCount, payload) |
||||||
|
} |
||||||
|
|
||||||
|
// 当第n个数据被获取,更新第n+1个position |
||||||
|
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { |
||||||
|
adapterDataObserver.onItemRangeInserted(positionStart + headerCount, itemCount) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) { |
||||||
|
adapterDataObserver.onItemRangeRemoved(positionStart + headerCount, itemCount) |
||||||
|
} |
||||||
|
|
||||||
|
override fun onItemRangeMoved(fromPosition: Int, toPosition: Int, itemCount: Int) { |
||||||
|
super.onItemRangeMoved(fromPosition + headerCount, toPosition + headerCount, itemCount) |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue