jdsjlzx / LRecyclerView

RecyclerView下拉刷新,自动加载更多;仿IOS侧滑Item删除菜单(盼望大家扩展更多功能)
http://blog.csdn.net/jdsjlzx/article/details/51794220
Apache License 2.0
2.47k stars 599 forks source link

跟MultiType库不一起用 #335

Open liuyuan1993 opened 5 years ago

liuyuan1993 commented 5 years ago

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

KotlinLan commented 5 years ago

可以这样试一试,这边测试没有问题。 修改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); }