Skip to content

Commit

Permalink
bug修复
Browse files Browse the repository at this point in the history
  • Loading branch information
梁任彦 committed Jul 5, 2018
1 parent 4b5c90a commit 397d6fa
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
};

public HeaderViewAdapter(RecyclerView.Adapter adapter) {
this.mAdapter = adapter;
mAdapter = adapter;
if (mAdapter != null) {
//注册mAdapter的数据变化监听
mAdapter.registerAdapterDataObserver(mObserver);
Expand Down Expand Up @@ -121,7 +121,7 @@ public int getItemViewType(int position) {
}

/**
* 设置被包装的adapter。
* 设置被包装的adapter。同一个adapter对象不能设置多次。
*
* @param adapter
*/
Expand All @@ -130,7 +130,11 @@ public void setAdapter(RecyclerView.Adapter adapter) {
//被包装的adapter不能是HeaderViewAdapter。
throw new IllegalArgumentException("Cannot wrap a HeaderViewAdapter");
}
this.mAdapter = adapter;
mAdapter = adapter;
if (mAdapter != null) {
//注册mAdapter的数据变化监听
mAdapter.registerAdapterDataObserver(mObserver);
}
notifyDataSetChanged();
}

Expand Down

0 comments on commit 397d6fa

Please sign in to comment.