diff --git a/gradle.properties b/gradle.properties index 0ac56a9..8d98ef7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ -VERSION_NAME=0.4.2 + +VERSION_NAME=0.4.3 GROUP=com.eowise diff --git a/library/src/main/java/com/eowise/recyclerview/stickyheaders/StickyHeadersItemDecoration.java b/library/src/main/java/com/eowise/recyclerview/stickyheaders/StickyHeadersItemDecoration.java index 19feca5..f717bb5 100644 --- a/library/src/main/java/com/eowise/recyclerview/stickyheaders/StickyHeadersItemDecoration.java +++ b/library/src/main/java/com/eowise/recyclerview/stickyheaders/StickyHeadersItemDecoration.java @@ -119,6 +119,11 @@ public void onChanged() { public void onItemRangeRemoved(int positionStart, int itemCount) { headerStore.onItemRangeRemoved(positionStart, itemCount); } + + @Override + public void onItemRangeInserted(int positionStart, int itemCount) { + headerStore.onItemRangeInserted(positionStart, itemCount); + } } private class HeaderStore { @@ -173,6 +178,23 @@ public void onItemRangeRemoved(int positionStart, int itemCount) { cleanOffScreenItemsIds(); } + public void onItemRangeInserted(int positionStart, int itemCount) { + boolean isCleanOffScreenItemsIdsNeeded = false; + for (int i = 0; i <= itemCount; i++) { + RecyclerView.ViewHolder holder = parent.findViewHolderForPosition(positionStart + i); + if (holder != null) { + isHeadersByItemsIds.remove(holder.getItemId()); + } + else { + isCleanOffScreenItemsIdsNeeded = true; + } + } + + if (isCleanOffScreenItemsIdsNeeded) { + cleanOffScreenItemsIds(); + } + } + public void clear() { headersViewByHeadersIds.clear(); isHeadersByItemsIds.clear();