Skip to content
New issue

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

跟MultiType库不一起用 #335

Open
liuyuan1993 opened this issue Apr 23, 2019 · 1 comment
Open

跟MultiType库不一起用 #335

liuyuan1993 opened this issue Apr 23, 2019 · 1 comment

Comments

@liuyuan1993
Copy link

发现跟网上开源的MultiType库不能一起用

@KotlinLan
Copy link

可以这样试一试,这边测试没有问题。
修改LRecyclerViewAdapter类。找到onViewAttachedToWindow和onViewDetachedFromWindow方法,作出如下修改:

@Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {

//增加判断1
if (isHeader(holder.getLayoutPosition()) || isRefreshHeader(holder.getLayoutPosition()) || isFooter(holder.getLayoutPosition())) {
super.onViewAttachedToWindow(holder);
return;
}
ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams();
if (lp != null && lp instanceof StaggeredGridLayoutManager.LayoutParams) {
if (isHeader(holder.getLayoutPosition()) || isRefreshHeader(holder.getLayoutPosition()) || isFooter(holder.getLayoutPosition())) {
StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp;
p.setFullSpan(true);
}
}

    mInnerAdapter.onViewAttachedToWindow(holder);
}

@Override
public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {

//增加判断2
if (isHeader(holder.getLayoutPosition()) || isRefreshHeader(holder.getLayoutPosition()) || isFooter(holder.getLayoutPosition())) {
super.onViewDetachedFromWindow(holder);
return;
}
mInnerAdapter.onViewDetachedFromWindow(holder);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants