We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在使用AutoDisposePagedListAdapter对RecyclerView.ViewHolder进行管理时,发现一个问题: 在CustomeAdapter的CustomeViewHolder中使用如下代码设置item的点击事件时,此时如果更新pageList中的数据(是更新不是插入或者删除),RecyclerView会走onBindViewHolder(),之后会导致item的点击事件失效。
view.clicks() .map { position } .autoDisposable(this) .subscribe(subject)
进一步分析之后,大致原因在于更新数据时,RecyclerView会先onBindViewHolder(),再调用onViewRecycled()对item资源进行回收。OnUnbindsPosition使被更新的Item点击事件失效了。虽然大致知道了问题,如果只是更新一项的话,我通过记录position可以解决问题,但是当更新的项有多个时就无从下手了。 AutoDisposePagedListAdapter中的代码:
@CallSuper override fun onBindViewHolder(holder: VH, position: Int) { when (holder) { is AutoDisposeViewHolder -> { holder.resetBindEvents(this) } } } @CallSuper override fun onViewRecycled(holder: VH) { super.onViewRecycled(holder) when (holder) { is AutoDisposeViewHolder -> { postViewHolderEvent( AutoDisposeViewHolder.ViewHolderEvent.OnUnbindsPosition( holder.adapterPosition ) ) } } }
求大神指导。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在使用AutoDisposePagedListAdapter对RecyclerView.ViewHolder进行管理时,发现一个问题:
在CustomeAdapter的CustomeViewHolder中使用如下代码设置item的点击事件时,此时如果更新pageList中的数据(是更新不是插入或者删除),RecyclerView会走onBindViewHolder(),之后会导致item的点击事件失效。
view.clicks() .map { position } .autoDisposable(this) .subscribe(subject)
进一步分析之后,大致原因在于更新数据时,RecyclerView会先onBindViewHolder(),再调用onViewRecycled()对item资源进行回收。OnUnbindsPosition使被更新的Item点击事件失效了。虽然大致知道了问题,如果只是更新一项的话,我通过记录position可以解决问题,但是当更新的项有多个时就无从下手了。
AutoDisposePagedListAdapter中的代码:
求大神指导。
The text was updated successfully, but these errors were encountered: