Skip to content

Commit

Permalink
Fix ArrayIndexOutOfBoundsException.
Browse files Browse the repository at this point in the history
  • Loading branch information
YoKeyword committed Mar 5, 2017
1 parent 593c662 commit e5f85a9
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ int getHeaderFooterType() {

public void addData(int position, T data) {
int size = mEntityWrapperList.size();
if (position > size) {
if (position >= size) {
return;
}

EntityWrapper<T> wrapper = wrapEntity(position);
EntityWrapper<T> wrapper = wrapEntity(position + 1);
wrapper.setItemType(getItemViewType());
wrapper.setData(data);

if (size > 0) {
mDataSetObservable.notifyAdd(getHeaderFooterType() == EntityWrapper.TYPE_HEADER, mEntityWrapperList.get(position - 1), wrapper);
mDataSetObservable.notifyAdd(getHeaderFooterType() == EntityWrapper.TYPE_HEADER, mEntityWrapperList.get(position), wrapper);
mIndexBarDataSetObservable.notifyChanged();
}
}
Expand All @@ -131,11 +131,11 @@ public void addDatas(List<T> datas) {

public void addDatas(int position, List<T> datas) {
int size = mEntityWrapperList.size();
if (position > size) {
if (position >= size) {
return;
}

for (int i = datas.size() - 1; i >= 0 ; i--) {
for (int i = datas.size() - 1; i >= 0; i--) {
addData(position, datas.get(i));
}
}
Expand Down

0 comments on commit e5f85a9

Please sign in to comment.