Skip to content

Commit

Permalink
fix 修复在指定位置添加一组数据
Browse files Browse the repository at this point in the history
  • Loading branch information
youlookwhat committed Jan 13, 2020
1 parent afa0b66 commit 36452ef
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ public void setRecyclerView(ByRecyclerView recyclerView) {
mRecyclerView = recyclerView;
}

/**
* 在指定位置添加一条数据
*/
public void addData(int position, T data) {
mData.add(position, data);
position = position + getCustomTopItemViewCount();
notifyItemRangeInserted(position, 1);
notifyItemRangeInserted(position + getCustomTopItemViewCount(), 1);
compatibilityDataSizeChanged(1);
}

Expand All @@ -93,11 +95,12 @@ public void addData(List<T> data) {
compatibilityDataSizeChanged(data.size());
}

/**
* 在指定位置添加一组数据
*/
public void addData(int position, List<T> data) {
int startPosition = mData.size();
this.mData.addAll(data);
startPosition = startPosition + getCustomTopItemViewCount();
notifyItemRangeInserted(startPosition, data.size());
this.mData.addAll(position, data);
notifyItemRangeInserted(position + getCustomTopItemViewCount(), data.size());
compatibilityDataSizeChanged(data.size());
}

Expand Down

0 comments on commit 36452ef

Please sign in to comment.