Skip to content

Commit

Permalink
fix remove() crash when have header view
Browse files Browse the repository at this point in the history
  • Loading branch information
ChadCym committed Mar 25, 2017
1 parent f37bd06 commit 9dd7033
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,10 @@ public void addData(T data) {
*/
public void remove(int position) {
mData.remove(position);
notifyItemRemoved(position + getHeaderLayoutCount());
int internalPosition = position + getHeaderLayoutCount();
notifyItemRemoved(internalPosition);
compatibilityDataSizeChanged(0);
notifyItemRangeChanged(position, mData.size() - position);
notifyItemRangeChanged(internalPosition, mData.size() - internalPosition);
}

/**
Expand Down Expand Up @@ -798,7 +799,7 @@ private void bindViewClickListener(final BaseViewHolder baseViewHolder) {
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getOnItemClickListener() != null&&baseViewHolder!=null) {
if (getOnItemClickListener() != null && baseViewHolder != null) {

getOnItemClickListener().onItemClick(BaseQuickAdapter.this, v, baseViewHolder.getLayoutPosition() - getHeaderLayoutCount());
}
Expand All @@ -808,7 +809,7 @@ public void onClick(View v) {
view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (getOnItemLongClickListener() != null&&baseViewHolder!=null) {
if (getOnItemLongClickListener() != null && baseViewHolder != null) {
return getOnItemLongClickListener().onItemLongClick(BaseQuickAdapter.this, v, baseViewHolder.getLayoutPosition() - getHeaderLayoutCount());
}
return false;
Expand Down

0 comments on commit 9dd7033

Please sign in to comment.