Skip to content
This repository has been archived by the owner on Nov 12, 2023. It is now read-only.

Commit

Permalink
fix index out of bounds exception when notifyItemChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
chuross committed Mar 29, 2018
1 parent 40e3db5 commit 6dd2070
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@ public long getItemId(int position) {
@Override
public void onViewAttachedToWindow(final VH holder) {
super.onViewAttachedToWindow(holder);
final int position = getPosition(holder);
if (position < 0) return;

holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final int position = getPosition(holder);
if (position < 0) return;
if (clickListener != null) clickListener.onItemClicked(holder, position, get(position));
}
});

holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
final int position = getPosition(holder);
if (position < 0) return false;
if (longPressedListener != null) longPressedListener.onItemLongPressed(holder, position, get(position));
return true;
}
Expand Down

0 comments on commit 6dd2070

Please sign in to comment.