From 7c5d2e834789d17862e6d75c36fef186096b5774 Mon Sep 17 00:00:00 2001 From: Michael Totschnig Date: Sat, 5 Mar 2016 14:11:50 +0100 Subject: [PATCH] prevent possible race condition hwere position is no longer valid, when click handler is run --- .../se/emilsjolander/stickylistheaders/AdapterWrapper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/src/se/emilsjolander/stickylistheaders/AdapterWrapper.java b/library/src/se/emilsjolander/stickylistheaders/AdapterWrapper.java index fb363a9d..d9355da9 100644 --- a/library/src/se/emilsjolander/stickylistheaders/AdapterWrapper.java +++ b/library/src/se/emilsjolander/stickylistheaders/AdapterWrapper.java @@ -137,7 +137,7 @@ private View configureHeader(WrapperView wv, final int position) { @Override public void onClick(View v) { - if(mOnHeaderClickListener != null){ + if(mOnHeaderClickListener != null && position < getCount()){ long headerId = mDelegate.getHeaderId(position); mOnHeaderClickListener.onHeaderClick(v, position, headerId); } @@ -147,7 +147,7 @@ public void onClick(View v) { @Override public boolean onLongClick(View v) { - if(mOnHeaderClickListener != null){ + if(mOnHeaderClickListener != null && position < getCount()){ long headerId = mDelegate.getHeaderId(position); return mOnHeaderClickListener.onHeaderLongClick(v, position, headerId); }